home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / unix / volume25 / finger / part02 < prev    next >
Encoding:
Text File  |  1992-04-04  |  68.5 KB  |  2,848 lines

  1. Newsgroups: comp.sources.unix
  2. From: phil@Shiva.COM (Phil Budne)
  3. Subject: v25i165: finger - Phil's Finger Program, Part02/07
  4. Sender: unix-sources-moderator@pa.dec.com
  5. Approved: vixie@pa.dec.com
  6.  
  7. Submitted-By: phil@Shiva.COM (Phil Budne)
  8. Posting-Number: Volume 25, Issue 165
  9. Archive-Name: finger/part02
  10.  
  11. #! /bin/sh
  12. # This is a shell archive.  Remove anything before this line, then unpack
  13. # it by saving it into a file and typing "sh file".  To overwrite existing
  14. # files, type "sh file -c".  You can also feed this as standard input via
  15. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  16. # will see the following message at the end:
  17. #        "End of archive 2 (of 7)."
  18. # Contents:  Makefile SAMPLE-local.h TODO args.h checkmode.c daemon.c
  19. #   finger.conf.5 finger.h getttytype.c getut.c kmem.c lastlog.c
  20. #   luser.h newmanifest.c nttyloc.5 string.c switch.h syms.h ttyloc.1
  21. #   ttyloc.c uptime.c ustruct.h whoj.c
  22. # Wrapped by budd@bu-it on Fri Jul  6 13:22:00 1990
  23. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  24. if test -f Makefile -a "${1}" != "-c" ; then 
  25.   echo shar: Will not over-write existing file \"Makefile\"
  26. else
  27. echo shar: Extracting \"Makefile\" \(2551 characters\)
  28. sed "s/^X//" >Makefile <<'END_OF_Makefile'
  29. X# Copyright (C) 1987, 1990  Philip L. Budne
  30. X#
  31. X# This file is part of "Phil's Finger Program".
  32. X#
  33. X# This program is free software; you can redistribute it and/or modify
  34. X# it under the terms of the GNU General Public License as published by
  35. X# the Free Software Foundation; either version 1, or (at your option)
  36. X# any later version.
  37. X#
  38. X
  39. X# $Id: Makefile,v 3.0 90/07/06 13:10:14 budd Rel $
  40. X
  41. X# Needed under AIX/RT
  42. XSHELL=/bin/sh
  43. X#
  44. XMAKEFILE_CPP=/lib/cpp -P
  45. X#
  46. X# If your cpp does not have -P (omit "# line")
  47. X#MAKEFILE_CPP=/lib/cpp | grep -v ^#
  48. X# If you are missing cpp?!
  49. X#MAKEFILE_CPP=cc -E | grep -v ^#
  50. X#
  51. X# cat -s on BSD means omit adjacent blank lines.
  52. X# on USG it means be quiet about missing files?!
  53. XCRUSH_BLANKS=| sed 's/[     ]*$$//' | cat -s
  54. X
  55. Xall:    DEPEND ALWAYS
  56. X    make -f xmakefile all
  57. X
  58. Xquick:    ALWAYS
  59. X    touch DEPEND
  60. X    make -f xmakefile all
  61. X
  62. Xxf:    DEPEND ALWAYS
  63. X    make -f xmakefile xf
  64. X
  65. Xttyloc:    DEPEND ALWAYS
  66. X    make -f xmakefile ttyloc
  67. X
  68. Xttyask:    DEPEND ALWAYS
  69. X    make -f xmakefile ttyask
  70. X
  71. Xfingerd: DEPEND ALWAYS
  72. X    make -f xmakefile fingerd
  73. X
  74. Xtar finger.tar:    xmakefile ALWAYS
  75. X    make -f xmakefile tar
  76. X
  77. Xkit shar: xmakefile ALWAYS
  78. X    make -f xmakefile kit
  79. X
  80. Xdist:    xmakefile ALWAYS
  81. X    make -f xmakefile dist
  82. X
  83. XTAGS:    xmakefile ALWAYS
  84. X    make -f xmakefile TAGS
  85. X
  86. Xclean:    xmakefile ALWAYS
  87. X    make -f xmakefile clean
  88. X    rm -f CROCK DEPEND
  89. X
  90. Xrealclean: xmakefile ALWAYS
  91. X    make -f xmakefile realclean
  92. X    rm -f CROCK DEPEND
  93. X
  94. Xxmakefile: CROCK ymakefile local.h
  95. X    @echo '# do not edit this file, created from ymakefile' > xmakefile
  96. X    $(MAKEFILE_CPP) ymakefile $(CRUSH_BLANKS)        >> xmakefile
  97. X    echo '# DO NOT DELETE THIS LINE -- make depend uses it' >> xmakefile
  98. X
  99. Xdepend DEPEND: xmakefile
  100. X    make -f xmakefile depend
  101. X    touch DEPEND
  102. X
  103. Xinstall: Install
  104. X    @echo "Run the shell script ./Install if you dare"
  105. X
  106. XInstall: Install.cpp local.h
  107. X    @echo '#!/bin/sh' > Install
  108. X    @echo '# do not edit this file, created from Install.cpp' >> Install
  109. X    $(MAKEFILE_CPP) Install.cpp $(CRUSH_BLANKS) >> Install
  110. X    chmod +x Install
  111. X
  112. X# must be executed in sequence!
  113. X# (.ORDER is honored by Encore make)
  114. X.ORDER CROCK: mywhoami getgroup checkmode local.h
  115. X    @touch CROCK
  116. X
  117. Xlocal.h:
  118. X    ./autoconfig > local.h.tmp && mv local.h.tmp local.h
  119. X
  120. Xmywhoami: mywhoami.c
  121. X    $(CC) $(CFLAGS) -o mywhoami mywhoami.c
  122. X
  123. Xgetgroup: getgroup.c
  124. X    $(CC) $(CFLAGS) -o getgroup getgroup.c
  125. X
  126. Xcheckmode: checkmode.c
  127. X    $(CC) $(CFLAGS) -o checkmode checkmode.c
  128. X
  129. Xdefs:
  130. X    grep '^#[     ]*if' *.[ch] > defs
  131. X    grep '^#[     ]*define' *.[ch] > defs
  132. X
  133. Xdefs.out: defs
  134. X    sh defs.sh > defs.out
  135. X
  136. X# always needs making
  137. XALWAYS:
  138. X
  139. X# A monument to a hack of long ago and far away...
  140. Xlove:
  141. X    @echo 'not war?'
  142. END_OF_Makefile
  143. if test 2551 -ne `wc -c <Makefile`; then
  144.     echo shar: \"Makefile\" unpacked with wrong size!
  145. fi
  146. # end of overwriting check
  147. fi
  148. if test -f SAMPLE-local.h -a "${1}" != "-c" ; then 
  149.   echo shar: Will not over-write existing file \"SAMPLE-local.h\"
  150. else
  151. echo shar: Extracting \"SAMPLE-local.h\" \(2003 characters\)
  152. sed "s/^X//" >SAMPLE-local.h <<'END_OF_SAMPLE-local.h'
  153. X/*
  154. X *    local.h for bu-it
  155. X *    created on Thu May 17 21:58:00 EDT 1990 by budd using autoconfig
  156. X */
  157. X
  158. X/* local-flags: *****************/
  159. X/* local-flags for bu-it */
  160. X
  161. X/*
  162. X# define INQUIRE
  163. X*/
  164. X
  165. X# define C_COMPILER gcc
  166. X# if 1
  167. X# define C_FLAGS -g -O
  168. X# else  /* not 1 */
  169. X# define C_FLAGS -W -Wreturn-type -Wunused -Wswitch -Wshadow -Wpointer-arith -Wcast-qual -Wpointer-arith -Wcast-qual -Dlint -g
  170. X# endif /* not 1 */
  171. X
  172. X# define DEBUGSW        /* include /debug switch */
  173. X# define UNPREFIX_NODOMAIN     /* unprefix hosts with no dots */
  174. X/* end of local-flags ***********/
  175. X
  176. X# define SunOS 403
  177. X
  178. X# define IN_DOT_DAEMON    /* internet daemon names prefixed with in. */
  179. X
  180. X# define LASTLOG            /* BSD last login file */
  181. X
  182. X# define SWAP_DEVICE "/dev/drum"    /* swap device */
  183. X
  184. X# define UNDERSCORE_NLIST_NAMES
  185. X
  186. X# define STREAMS
  187. X
  188. X# define SHORT_TTYP
  189. X
  190. X
  191. X# define TTY_GROUP_NUMBER 4
  192. X
  193. X# define TTY_GROUP "tty"
  194. X
  195. X/* for Install.cpp */
  196. X# define KMEM_GROUP kmem
  197. X
  198. X/* getpwnam(3) is fast (yellow pages) */
  199. X
  200. X# define HAVE_YP_MATCH            /* have yp_match(3) */
  201. X
  202. X# define ALIASES "/etc/aliases"    /* sendmail aliases file */
  203. X
  204. X# define TTYENT                /* use getttyent(3) */
  205. X
  206. X# define INETD                /* use inetd for fingerd */
  207. X
  208. X# define VOIDSIG            /* signal() declared as void * */
  209. X
  210. X/* utmp has ut_host field */
  211. X
  212. X# define KERNEL_FILE "/vmunix"
  213. X
  214. X# define MAIL_SPOOL "/usr/spool/mail"
  215. X
  216. X# define SYSLOG                /* fingerd does syslog-ing */
  217. X
  218. X# define SAVED_NLIST "/etc/finger-saved-nlist" /* save nlist to this file */
  219. X
  220. X# define AUTONLIST            /* update nlist save file as needed */
  221. X
  222. X# define NLIST_MODE 0664        /* creation mode for nlist file */
  223. X
  224. X# define NETBERK            /* network finger implies /berk */
  225. X                    /* (I hate this) */
  226. X
  227. X# define NETFOLLOW            /* net finger implies /follow */
  228. X
  229. X/**************** REQUIRED!! (used by Install) ****************/
  230. X
  231. X# define TTYLOC_DIR "/usr/spool/ttyloc"
  232. X
  233. X# define TTYLOC_MODE 0644
  234. X
  235. X/* extra paths to try to exec finger */
  236. X/* # define FINGERPATHS "/usr/local/local/bin/finger", "/bin/who" /*  */
  237. X
  238. X/*
  239. X * Local variables:
  240. X * comment-column: 40
  241. X * End:
  242. X */
  243. END_OF_SAMPLE-local.h
  244. if test 2003 -ne `wc -c <SAMPLE-local.h`; then
  245.     echo shar: \"SAMPLE-local.h\" unpacked with wrong size!
  246. fi
  247. # end of overwriting check
  248. fi
  249. if test -f TODO -a "${1}" != "-c" ; then 
  250.   echo shar: Will not over-write existing file \"TODO\"
  251. else
  252. echo shar: Extracting \"TODO\" \(2202 characters\)
  253. sed "s/^X//" >TODO <<'END_OF_TODO'
  254. XALSO: grep for TODO in source files
  255. X==
  256. XOUTPUT FORMAT:
  257. X1.    /fields[:sep]
  258. X
  259. X#4. clean up /follow
  260. X-    trace at tree building time? (insert locals)
  261. X        store where?
  262. X-    warn about loops in man page
  263. X-    avoid local loops
  264. X-    handle "", pipes, files
  265. X
  266. X5. lint + GLOBAL/LOCAL + void + extern int foo();
  267. X
  268. X6. update copyrights (date, and notice)
  269. X
  270. X#7. INSTALL:
  271. X    do install via Makefile?
  272. X    Install man pages
  273. X
  274. X8.    faster lookup when /match?
  275. X
  276. X9.    always try getpwbyname (even when using inquire)
  277. X
  278. X#10.    keep ttylocs and default ttylocs in a binary file? dbm?
  279. X    see comments at top of getttyloc.c
  280. X
  281. XDOCUMENT:
  282. X11.    readttylocfile(3)
  283. X12.    getttytype(3)
  284. X#13.    Document all defines.
  285. X
  286. X#14.    update autoconfig
  287. X
  288. X==
  289. X
  290. X#15.    -help print copyright? (or at least point to it)
  291. X    help too long?? feed to more?
  292. X
  293. X16.    -help say that /foll/berk are set by remote fingers (conditionally
  294. X    compile!!)
  295. X
  296. X#17.    A way to say "-v"@host to pass switches to 4n hosts
  297. X
  298. X#22.    Be able to continue without read_vmunix. (see PICKY in names.c)
  299. X
  300. X21.
  301. X    non-compile oriented config (esp PREFIXes)
  302. X        - office prefixes (sort by length (longest first?))
  303. X        - host prefixes
  304. X        - hosts to forward to other hosts (DECnet hosts...)
  305. X          (check MX records??)
  306. X        - other stuff
  307. X
  308. X#24.    penalize for pause() or wait() ?? (done 3/10/88)
  309. X
  310. X27.    whoj with X11 hostname fails (. tickles unprefix)
  311. X    use of undomain in that context is bogus.
  312. X
  313. X28.    print a message when a 4n finger shuts down without sending any data
  314. X
  315. X31.    show terminal input state? (or lack thereof)
  316. X    display * for runnable?
  317. X
  318. X33.    do getpwuid( getpwnam( match )->pw_uid )
  319. X    helps with dual names for same uid?? (but is slow!)
  320. X
  321. X#34.    Use comments on #else #endif (fuat)
  322. X
  323. X#35.    Blast ZUPing of hosts (stu)
  324. X
  325. X#36.    Do getNETbynumber on unknown hosts!! (fingerd, ttyloc)
  326. X    ie; convert 10.0.0.9 to arpa.9?
  327. X    128.197.20.40 to bu-net.20.40?
  328. X
  329. X37.    show swapped after progrname (if room).
  330. X    what char to use?
  331. X
  332. X38.    More bits in p_flags under SunOS 4.0:
  333. X    SULOCK SKEEP SPGLDR SFAVORD
  334. X
  335. X39.    figure out stream tty status?
  336. X
  337. X40.    Use sendmailbox (provide small one?)
  338. X
  339. X# Don't count these!!
  340. X#5/9/88    32 + 17 = 49
  341. X#5/17    23 + 15 = 38
  342. X#6/9    21 + 19 = 40
  343. X#6/27    22 + 10 = 32
  344. X#7/5    16 + 10 = 27
  345. X#10/26    16 + 11 = 29
  346. X#6/15/89 9 + 19 = 28
  347. X#6/28/89 9 + 15 = 24
  348. X#7/6/90    17 + 11 = 38
  349. END_OF_TODO
  350. if test 2202 -ne `wc -c <TODO`; then
  351.     echo shar: \"TODO\" unpacked with wrong size!
  352. fi
  353. # end of overwriting check
  354. fi
  355. if test -f args.h -a "${1}" != "-c" ; then 
  356.   echo shar: Will not over-write existing file \"args.h\"
  357. else
  358. echo shar: Extracting \"args.h\" \(1956 characters\)
  359. sed "s/^X//" >args.h <<'END_OF_args.h'
  360. X/*
  361. X * args.h -- flag/switch definitions
  362. X *
  363. X * Copyright (C) 1986, 1990  Philip L. Budne
  364. X *
  365. X * This file is part of "Phil's Finger Program".
  366. X *
  367. X * This program is free software; you can redistribute it and/or modify
  368. X * it under the terms of the GNU General Public License as published by
  369. X * the Free Software Foundation; either version 1, or (at your option)
  370. X * any later version.
  371. X *
  372. X */
  373. X
  374. X# define ARGS_RCSID "$Id: args.h,v 3.0 90/07/06 13:10:20 budd Rel $"
  375. X
  376. X# ifndef EXTERN
  377. X# define EXTERN extern
  378. X# endif /* EXTERN not defined */
  379. X
  380. X/* global (not per-person) switches */
  381. Xtypedef char sw_t;
  382. X
  383. XEXTERN sw_t sw_age;        /* age switch */
  384. X                /* display on rather than idle */
  385. XEXTERN sw_t sw_berkeley;    /* be like bzerkly finger */
  386. X                /* (force -w -p with names) */
  387. XEXTERN sw_t sw_debug;        /* enable debug output */
  388. XEXTERN sw_t sw_follow;        /* let finger do the walking */
  389. X                /* cudos to CTorek for the idea */
  390. XEXTERN sw_t sw_its;        /* be more like ITS (default is Twenex; */
  391. XEXTERN sw_t sw_jobs;        /* do whoj display */
  392. XEXTERN sw_t sw_nosave;        /* prohibit write of nlist */
  393. X                /* this is forced on by 'xf' */
  394. XEXTERN sw_t sw_output;        /* display idle time based on last output */
  395. XEXTERN sw_t sw_pid;        /* show current process pid */
  396. XEXTERN sw_t sw_read;        /* force read of nlist, and save */
  397. X                /* do this from your rc file */
  398. X                /* if you don't use AUTONLIST */
  399. XEXTERN sw_t sw_state;        /* show process state in place of idle */
  400. XEXTERN sw_t sw_whois;        /* whois switch -- show long information */
  401. X
  402. XEXTERN char *sw_fields;        /* NYI: display output in AWKable form */
  403. X
  404. X/****************
  405. X * flags processed per-user
  406. X */
  407. X
  408. XEXTERN struct switches {
  409. X    int sw_location    : 1;    /* ignore user location */
  410. X    int sw_mail        : 1;    /* force mail check */
  411. X    int sw_match    : 1;    /* match on usernames only */
  412. X    int sw_noplan    : 1;    /* prhibit display of plan under /whois */
  413. X    int sw_plan        : 1;    /* check for ~/.plan file */
  414. X} Sw;
  415. X
  416. X/*
  417. X * Local variables:
  418. X * comment-column: 32
  419. X * End:
  420. X */
  421. END_OF_args.h
  422. if test 1956 -ne `wc -c <args.h`; then
  423.     echo shar: \"args.h\" unpacked with wrong size!
  424. fi
  425. # end of overwriting check
  426. fi
  427. if test -f checkmode.c -a "${1}" != "-c" ; then 
  428.   echo shar: Will not over-write existing file \"checkmode.c\"
  429. else
  430. echo shar: Extracting \"checkmode.c\" \(3214 characters\)
  431. sed "s/^X//" >checkmode.c <<'END_OF_checkmode.c'
  432. X/*
  433. X * checkmode.c -- check file modes
  434. X *
  435. X * Copyright (C) 1990 Philip L. Budne
  436. X *
  437. X * This program is free software; you can redistribute it and/or modify
  438. X * it under the terms of the GNU General Public License as published by
  439. X * the Free Software Foundation; either version 1, or (at your option)
  440. X * any later version.
  441. X *
  442. X */
  443. X
  444. X# ifndef lint
  445. Xstatic char *rcsid = "$Id: checkmode.c,v 3.0 90/07/06 13:10:25 budd Rel $";
  446. Xstatic char Copyright[] = "Copyright (C) 1990 Philip L. Budne";
  447. X# endif /* lint not defined */
  448. X
  449. X# include <sys/types.h>
  450. X# include <sys/stat.h>
  451. X# include <stdio.h>
  452. X
  453. X# define EOS '\0'
  454. X
  455. X# ifndef S_IRUSR            /* sigh */
  456. X# define S_IRUSR 0000400        /* read permission, owner */
  457. X# define S_IWUSR 0000200        /* write permission, owner */
  458. X# define S_IXUSR 0000100        /* execute/search permission, owner */
  459. X# define S_IRGRP 0000040        /* read permission, group */
  460. X# define S_IWGRP 0000020        /* write permission, grougroup */
  461. X# define S_IXGRP 0000010        /* execute/search permission, group */
  462. X# define S_IROTH 0000004        /* read permission, other */
  463. X# define S_IWOTH 0000002        /* write permission, other */
  464. X# define S_IXOTH 0000001        /* execute/search permission, other */
  465. X# endif /* S_IRUSR not defined */
  466. X
  467. X# define USER    (S_IRUSR|S_IWUSR|S_IXUSR|S_ISUID)
  468. X# define GROUP    (S_IRGRP|S_IWGRP|S_IXGRP|S_ISGID)
  469. X# define OTHER    (S_IROTH|S_IWOTH|S_IXOTH)
  470. X
  471. X# define READ    (S_IRUSR|S_IRGRP|S_IROTH)
  472. X# define WRITE    (S_IWUSR|S_IWGRP|S_IWOTH)
  473. X# define EXEC    (S_IXUSR|S_IXGRP|S_IXOTH)
  474. X
  475. X# define SET    (S_ISUID|S_ISGID)
  476. X
  477. X# define OCTAL(c) ((c) >= '0' && (c) <= '7')
  478. X
  479. Xint thing(), thing1();
  480. Xvoid bad();
  481. Xchar *cp;
  482. X
  483. Xvoid
  484. Xusage() {
  485. X    fprintf( stderr, "Usage checkmode file mode_mask [bits_set]\n" );
  486. X    exit( 1 );
  487. X}
  488. X
  489. Xint
  490. Xmain( c, v )
  491. X    int c;
  492. X    char **v;
  493. X{
  494. X    int mask, bits;
  495. X    char op;
  496. X    struct stat st;
  497. X
  498. X    if( c < 2 || c > 4 )
  499. X    usage();
  500. X
  501. X    mask = thing( v[2] );
  502. X    if( c == 3 )
  503. X    bits = mask;
  504. X    else
  505. X    bits = thing( v[3] );
  506. X
  507. X    if( *cp == '+' || *cp == '-' )
  508. X    op = *cp++;
  509. X    else
  510. X    op = '+';
  511. X
  512. X    if( stat( v[1], &st ) < 0 ) {
  513. X    perror( v[1] );
  514. X    exit( 2 );
  515. X    }
  516. X
  517. X    if( (st.st_mode & mask) == bits )
  518. X    exit( 0 );
  519. X    puts("nope");
  520. X    exit( 1 );
  521. X} /* main */
  522. X
  523. X# define PEEK (*cp)
  524. X# define NEXT (*cp++)
  525. X
  526. Xint
  527. Xthing( p )
  528. X    char *p;
  529. X{
  530. X    int m;
  531. X
  532. X    cp = p;
  533. X
  534. X    m = thing1();
  535. X    while( PEEK == '+' || PEEK == '-' ) {
  536. X    if( NEXT == '+' )
  537. X        m |= thing1();        /* add bits */
  538. X    else
  539. X        m &= ~thing1();        /* remove bits */
  540. X    }
  541. X    if( PEEK )
  542. X    bad();
  543. X    return( m );
  544. X} /* thing */
  545. X
  546. Xint
  547. Xthing1() {
  548. X    int m;
  549. X
  550. X    if( OCTAL(PEEK) ) {
  551. X    m = 0;
  552. X    do
  553. X        m = (m<<3) | NEXT - '0';
  554. X    while( OCTAL(PEEK) );
  555. X    return( m );
  556. X    }
  557. X
  558. X    switch( PEEK ) {
  559. X    case 'u':
  560. X    m = USER;
  561. X    NEXT;
  562. X    break;
  563. X    case 'g':
  564. X    m = GROUP;
  565. X    NEXT;
  566. X    break;
  567. X    case 'o':
  568. X    m = OTHER;
  569. X    NEXT;
  570. X    break;
  571. X# ifdef S_ISVTX
  572. X    case 't':
  573. X    NEXT;
  574. X    return( S_ISVTX );
  575. X# endif /* S_ISVTX defined */
  576. X    default:
  577. X    m = USER|GROUP|OTHER;
  578. X    break;
  579. X    }
  580. X
  581. X    switch( PEEK ) {
  582. X    case 'r':
  583. X    m &= READ;
  584. X    break;
  585. X    case 'w':
  586. X    m &= WRITE;
  587. X    break;
  588. X    case 'x':
  589. X    m &= EXEC;
  590. X    break;
  591. X    case 's':
  592. X    m &= SET;
  593. X    break;
  594. X    case EOS:
  595. X    return( m );
  596. X    default:
  597. X    bad();
  598. X    }
  599. X    NEXT;
  600. X    return( m );
  601. X}
  602. X
  603. Xvoid
  604. Xbad() {
  605. X    fprintf( stderr, "Bad character in mode '%c'\n", PEEK );
  606. X    usage();
  607. X}
  608. END_OF_checkmode.c
  609. if test 3214 -ne `wc -c <checkmode.c`; then
  610.     echo shar: \"checkmode.c\" unpacked with wrong size!
  611. fi
  612. # end of overwriting check
  613. fi
  614. if test -f daemon.c -a "${1}" != "-c" ; then 
  615.   echo shar: Will not over-write existing file \"daemon.c\"
  616. else
  617. echo shar: Extracting \"daemon.c\" \(2979 characters\)
  618. sed "s/^X//" >daemon.c <<'END_OF_daemon.c'
  619. X/*
  620. X * daemon.c -- Different things that can parent a shell -- January 1988
  621. X *
  622. X * Copyright (C) 1988, 1990  Philip L. Budne
  623. X *
  624. X * This file is part of "Phil's Finger Program".
  625. X *
  626. X * This program is free software; you can redistribute it and/or modify
  627. X * it under the terms of the GNU General Public License as published by
  628. X * the Free Software Foundation; either version 1, or (at your option)
  629. X * any later version.
  630. X *
  631. X */
  632. X
  633. X# ifndef lint
  634. Xstatic char *rcsid = "$Id: daemon.c,v 3.0 90/07/06 13:10:29 budd Rel $";
  635. X# endif /* lint not defined */
  636. X
  637. X# include "finger.h"
  638. X# include "daemon.h"
  639. X
  640. Xstruct daemon daemons [] = {
  641. X    /* cmd        short        long */
  642. X
  643. X# ifdef sun
  644. X# if SunOS >= 400
  645. X    {"cmdtool",        "cmdtool",    "SunView (cmdtool)" },
  646. X# endif /* SunOS >= 400 */
  647. X    {"suntools",    "suntools",    "SunView (suntools)" },
  648. X    {"vt100tool",    "vt100tool",    "SunView (vt100tool)" },
  649. X    {"othertools",    "othertools",    "SunView (othertools)" },
  650. X    {"dbxtool",        "dbxtool",    "SunView (dbxtool)" }, /* use ptys? */
  651. X    {"dnalogind",    "DNA",        "DNA login" },    /* Sun DECnet? */
  652. X    {"dnaserver",    "DNI",        "Sunlink/DNI" }, /* ditto? */
  653. X    {"psterm",        "NeWs",        "NeWs Window" },
  654. X# endif /* sun defined */
  655. X
  656. X# ifdef IN_DOT_DAEMON
  657. X    {"in.rlogind",    "rlogin",    "Remote Login" },
  658. X    {"in.telnetd",    "telnet",    "Telnet" },
  659. X    {"in.supdupd",    "supdup",    "Supdup" },
  660. X    {"in.rshd",        "rsh",        "Remote Shell" },
  661. X# else  /* IN_DOT_DAEMON not defined */
  662. X    {"rlogind",        "rlogin",    "Remote Login"},
  663. X    {"telnetd",        "telnet",    "Telnet" },
  664. X    {"supdupd",        "supdup",    "Supdup" },
  665. X    {"rshd",        "rsh",        "Remote Shell" },
  666. X# endif /* IN_DOT_DAEMON not defined */
  667. X
  668. X# ifdef ultrix
  669. X    {"dlogin",        "dlogin",    "DECnet Login" },
  670. X    {"dlogind",        "dlogin",    "DECnet Login" },
  671. X    {"dtermd",        "dterm",    "DECnet Terminal" }, /* cterm? */
  672. X    {"dnet_spawner",    "decnet",    "DECnet" },    /* SNH? */
  673. X    {"telnet.gw",    "telnet",    "Telnet GW" },    /* SNH? */
  674. X    {"dxterm",        "dxterm",    "X window" },
  675. X# endif /* ultrix defined */
  676. X
  677. X# ifdef sgi
  678. X    {"wsh",        "wsh",        "NeWs Window"},
  679. X    {"grcond",        "grcond",    "Graphics Console"},
  680. X# endif /* sgi defined */
  681. X
  682. X# if defined(AIX_RT) || defined(AIX_PS2) || defined(AIX3)
  683. X    {"aixterm",        "aixterm",    "X Window" },    /* no host in utmp */
  684. X# endif /* defined(AIX_RT) || defined(AIX_PS2) || defined(AIX3) */
  685. X
  686. X    {"xterm",        "xterm",    "X Window" },    /* no host in utmp */
  687. X
  688. X
  689. X    {"inetd",        "inet",        "Internet" },    /* SNH */
  690. X
  691. X    /* **************** put under ifdefs? **************** */
  692. X
  693. X    /* 4.3 XNS */
  694. X    {"GAP3d",        "GAP3",        "XNS GAP3" },
  695. X    {"xnscourierd",    "XNS",        "XNS Courier" }, /* snh */
  696. X
  697. X    /* MIT Chaosnet */
  698. X    {"TELNET",        "chtn",        "Chaos Telnet" },
  699. X    {"SUPDUP",        "chsupdup",    "Chaos" },    /* ever get this? */
  700. X    {"chserver",    "chaos",    "Chaosnet" },    /* snh */
  701. X
  702. X    /* Stanford PUP - Bill Nowicki and Jeff Mogul */
  703. X    {"telser",        "pup",        "PUP" },
  704. X
  705. X# ifdef LOCAL_DAEMONS
  706. X    LOCAL_DAEMONS,
  707. X# endif /* LOCAL_DAEMONS defined */
  708. X
  709. X    {0, 0, 0}
  710. X}; /* daemons[] */
  711. X
  712. X/*
  713. X * Local variables:
  714. X * comment-column: 56
  715. X * End:
  716. X */
  717. END_OF_daemon.c
  718. if test 2979 -ne `wc -c <daemon.c`; then
  719.     echo shar: \"daemon.c\" unpacked with wrong size!
  720. fi
  721. # end of overwriting check
  722. fi
  723. if test -f finger.conf.5 -a "${1}" != "-c" ; then 
  724.   echo shar: Will not over-write existing file \"finger.conf.5\"
  725. else
  726. echo shar: Extracting \"finger.conf.5\" \(2561 characters\)
  727. sed "s/^X//" >finger.conf.5 <<'END_OF_finger.conf.5'
  728. X.\" -*-nroff-*-
  729. X.\" $Id: finger.conf.5,v 3.0 90/07/06 13:10:39 budd Rel $
  730. X.\" Copyright (c) 1990  Philip L. Budne
  731. X.TH FINGER.CONF 5 "30 April 1990"
  732. X.UC 4
  733. X.SH NAME
  734. Xfinger.conf \- runtime configuration information for finger
  735. X.SH DESCRIPTION
  736. XThe
  737. X.I finger.conf
  738. Xfile allows
  739. X.IR finger (1)
  740. Xto be configured in a site-dependant manner at runtime.
  741. X.PP
  742. XIf the first character on a line is a exclamation mark (!), the line
  743. Xis ignored. The file is broken into sections initiated by a percent
  744. Xsign and section name at the start of a line.
  745. X.\" ----
  746. X.\" set tab stops
  747. X.ta \w'.DECNET\ \ 'u +\w'MCS'u 
  748. X.\" translate & to dot
  749. X.tr &.
  750. X.\" Begin Example
  751. X.de BE
  752. X.PP
  753. X\fC
  754. X.nf
  755. X..
  756. X.\" End Example
  757. X.de EE
  758. X\fR
  759. X.fi
  760. X..
  761. X.\" ====
  762. X.SS ACCOUNTS
  763. XInformation from the
  764. X.I accounts
  765. Xsection is used to display a group letter after the username in
  766. X.I finger
  767. Xoutput, and in
  768. X.I whois
  769. Xoutput to supply defaults for account and project.  The first column
  770. Xis a group name or number. A range of groups can be specified using a
  771. Xhyphen.  A backslash (\\) can be used to quote hyphens (or spaces!!)
  772. Xin group names.
  773. X.BE
  774. X%accounts
  775. Xstaff    +    Staff Wizards
  776. Xnseg    N    Networking Systems
  777. Xdsg    D    Distributed Systems
  778. Xcsg    C    Central Systems
  779. Xscv    V    Skeeve Group
  780. Xitother    I    Disinformation Technology
  781. Xusrsrv    U    User Disservices
  782. Xguest    G    Guest
  783. Xx\-y    X    The X-Y Group
  784. X0-9999    ?    The Great Unknown
  785. X.EE
  786. X.\" ----
  787. X.SS BUILDINGS
  788. XThe
  789. X.I buildings
  790. Xsection is used to expand GECOS office locations in a site independant
  791. Xmanner for
  792. X.I whois
  793. Xoutput.
  794. X.BE
  795. X%buildings
  796. XM    MCS
  797. XA    ACC
  798. XC    CS
  799. XE    ERB
  800. X.EE
  801. X.\" ----
  802. X.SS HIDDEN
  803. XThe
  804. X.I hidden
  805. Xsection is used to discourage display of programs names that are
  806. Xuninteresting.
  807. X.BE
  808. X%hidden
  809. Xgamescontrol
  810. X.EE
  811. X.\" ----
  812. X.SS PHONES
  813. XThe
  814. X.I buildings
  815. Xsection is used to expand GECOS phone numbers in a site independant
  816. Xmanner for
  817. X.I whois
  818. Xoutput. The first format in which the number of pound signs matches
  819. Xthe number of digits in the phone number to be printed is used.
  820. X.BE
  821. X%phones
  822. Xx3-####
  823. Xx#-####
  824. Xx####
  825. X(617) ###-####
  826. X(###) ###-####
  827. X.EE
  828. X.\" ----
  829. X.SS PREFIXES
  830. XThe
  831. X.I prefixes
  832. Xsection is used to remove hostname prefixes for shortened display
  833. Xbefore ttyloc information.
  834. X.BE
  835. X%prefixes
  836. XBUIT
  837. XBU-
  838. XBU
  839. X.EE
  840. X.\" ----
  841. X.\" .SS ROUTES
  842. X.\" The
  843. X.\" .I routes
  844. X.\" section is not yet implemented.
  845. X.\" .PP
  846. X.\" .BE 
  847. X.\" %routes
  848. X.\" &DECNET    @\fRdecnet_router_host\fP
  849. X.\" .EE
  850. X.\" ====
  851. X.SH FILES
  852. X.ta \w'/usr/local/etc/finger.conf\ \ 'u
  853. X.nf
  854. X/etc/finger.conf    First try
  855. X/usr/local/etc/finger.conf    Second try
  856. X/usr/etc/finger.conf    Third try
  857. X&/finger.conf        Last try
  858. X.fi
  859. X.\" ====
  860. X.SH "SEE ALSO"
  861. Xfinger(1), nttyloc(5)
  862. X.\" ====
  863. X.SH AUTHOR
  864. XPhilip L. Budne
  865. END_OF_finger.conf.5
  866. if test 2561 -ne `wc -c <finger.conf.5`; then
  867.     echo shar: \"finger.conf.5\" unpacked with wrong size!
  868. fi
  869. # end of overwriting check
  870. fi
  871. if test -f finger.h -a "${1}" != "-c" ; then 
  872.   echo shar: Will not over-write existing file \"finger.h\"
  873. else
  874. echo shar: Extracting \"finger.h\" \(1904 characters\)
  875. sed "s/^X//" >finger.h <<'END_OF_finger.h'
  876. X/*
  877. X * finger.h - basic language defines for finger etc
  878. X *
  879. X * Copyright (C) 1988, 1990  Philip L. Budne
  880. X *
  881. X * This file is part of "Phil's Finger Program".
  882. X *
  883. X * This program is free software; you can redistribute it and/or modify
  884. X * it under the terms of the GNU General Public License as published by
  885. X * the Free Software Foundation; either version 1, or (at your option)
  886. X * any later version.
  887. X *
  888. X */
  889. X
  890. X# define FINGER_RCSID "$Id: finger.h,v 3.0 90/07/06 13:10:41 budd Rel $"
  891. X
  892. X# ifndef _FINGER_H_
  893. X# define _FINGER_H_
  894. X
  895. X# include "local.h"
  896. X
  897. X# define EOS '\0'
  898. X
  899. X# define LOCAL static
  900. X# define GLOBAL
  901. X# define FORWARD
  902. X
  903. X# define BOOL int
  904. X# define FALSE 0
  905. X# define TRUE 1
  906. X
  907. X# ifndef lint
  908. XLOCAL char Copyright[] = "Copyright (C) 1986, 1990  Philip L. Budne";
  909. X# endif /* lint not defined */
  910. X
  911. X/* param.h (on 4.3) has MAXHOSTNAMELEN *TODO* */
  912. X# ifndef MAXHOSTLEN
  913. X# define MAXHOSTLEN 64
  914. X# endif /* MAXHOSTLEN not defined */
  915. X
  916. X# define BPW (sizeof(int)*8)
  917. X# define MINUS_INF (1<<(BPW-1))
  918. X# define PLUS_INF  (MINUS_INF-1)
  919. X
  920. Xextern char *savestr();            /* string.c */
  921. Xextern char *malloc();            /* libc */
  922. X
  923. X# ifdef __STDC__            /* f****d up ANSI C (accomodate GCC) */
  924. X
  925. X# define CONC(a,b) a##b            /* concatenate 2 strings */
  926. X# define CONC3(a,b,c) a##b##c        /* same for three */
  927. X# define STR(a) #a            /* make arg into a quoted string */
  928. X
  929. X# define SIGNED signed
  930. X
  931. X# else  /* __STDC__ not defined */
  932. X
  933. X# define CONC(a,b) a/**/b
  934. X# define CONC3(a,b,c) a/**/b/**/c
  935. X# define STR(s) "s"
  936. X
  937. X# define SIGNED
  938. X
  939. X# endif /* __STDC__ not defined */
  940. X
  941. X# ifndef INIT_PID
  942. X# define INIT_PID 1            /* Unix truism */
  943. X# endif /* INIT_PID not defined */
  944. X
  945. X# ifdef UPCASE_HOSTS
  946. X# define HZUP(s) zup(s)
  947. X# else  /* UPCASE_HOSTS not defined */
  948. X# define HZUP(s) s
  949. X# endif /* UPCASE_HOSTS not defined */
  950. X
  951. X/* std io descriptors */
  952. X# define STD_INPUT 0
  953. X# define STD_OUTPUT 1
  954. X
  955. X# endif /* _FINGER_H_ not defined */
  956. X
  957. X/*
  958. X * Local variables:
  959. X * comment-column: 40
  960. X * End:
  961. X */
  962. END_OF_finger.h
  963. if test 1904 -ne `wc -c <finger.h`; then
  964.     echo shar: \"finger.h\" unpacked with wrong size!
  965. fi
  966. # end of overwriting check
  967. fi
  968. if test -f getttytype.c -a "${1}" != "-c" ; then 
  969.   echo shar: Will not over-write existing file \"getttytype.c\"
  970. else
  971. echo shar: Extracting \"getttytype.c\" \(1782 characters\)
  972. sed "s/^X//" >getttytype.c <<'END_OF_getttytype.c'
  973. X/*
  974. X * getttytype.c -- get tty type for a line (July 1987)
  975. X *
  976. X * Copyright (C) 1987, 1990  Philip L. Budne
  977. X *
  978. X * This file is part of "Phil's Finger Program".
  979. X *
  980. X * This program is free software; you can redistribute it and/or modify
  981. X * it under the terms of the GNU General Public License as published by
  982. X * the Free Software Foundation; either version 1, or (at your option)
  983. X * any later version.
  984. X *
  985. X */
  986. X
  987. X# ifndef lint
  988. Xstatic char *rcsid = "$Id: getttytype.c,v 3.0 90/07/06 13:10:56 budd Rel $";
  989. X# endif /* lint not defined */
  990. X
  991. X# include <stdio.h>
  992. X# include "finger.h"
  993. X
  994. X# ifdef TTYENT
  995. X
  996. X# include <ttyent.h>
  997. X
  998. XGLOBAL char *getttytype( tty )
  999. Xchar *tty;
  1000. X{
  1001. X    register struct ttyent *ty;
  1002. X    register char *type;
  1003. X
  1004. X    setttyent();
  1005. X    if( (ty = getttynam( tty )) == NULL )
  1006. X    type = NULL;
  1007. X    else
  1008. X    type = ty->ty_type;
  1009. X
  1010. X    endttyent();
  1011. X    return( type );
  1012. X} /* 4.3 getttytype */
  1013. X
  1014. X# else  /* TTYENT not defined */
  1015. X
  1016. X# include <strings.h>
  1017. X
  1018. XGLOBAL char *getttytype( tty )
  1019. Xchar *tty;
  1020. X{
  1021. X    FILE *f;
  1022. X    char line[ 512 ];
  1023. X    char *cp, *type;
  1024. X    register char *sp;
  1025. X
  1026. X    if( (f = fopen("/etc/ttytype", "r")) == NULL )
  1027. X    return( NULL );
  1028. X
  1029. X    type = NULL;            /* be realistic */
  1030. X    while( fgets( line, sizeof( line ), f ) != NULL ) {
  1031. X    cp = line;
  1032. X    if( !skipwhite( &cp ) )
  1033. X        continue;
  1034. X
  1035. X    type = cp;
  1036. X    if( !skipblack( &cp ) )
  1037. X        continue;
  1038. X    *cp++ = EOS;            /* tie off type */
  1039. X
  1040. X    if( !skipwhite( &cp ) )        /* eat white. */
  1041. X        continue;
  1042. X
  1043. X    if( (sp = index(cp, '\n')) != NULL ) /* kill eol */
  1044. X        *sp = EOS;
  1045. X
  1046. X    if( strcmp( cp, tty ) != 0 ) {    /* match tty name? */
  1047. X        type = NULL;
  1048. X        continue;            /* no, back to work */
  1049. X    }
  1050. X    break;
  1051. X    } /* while */
  1052. X    fclose( f );
  1053. X    return( type );
  1054. X} /* 4.2 getttytype */
  1055. X# endif /* TTYENT not defined */
  1056. X
  1057. X/*
  1058. X * Local variables:
  1059. X * comment-column: 40
  1060. X * End:
  1061. X */
  1062. END_OF_getttytype.c
  1063. if test 1782 -ne `wc -c <getttytype.c`; then
  1064.     echo shar: \"getttytype.c\" unpacked with wrong size!
  1065. fi
  1066. # end of overwriting check
  1067. fi
  1068. if test -f getut.c -a "${1}" != "-c" ; then 
  1069.   echo shar: Will not over-write existing file \"getut.c\"
  1070. else
  1071. echo shar: Extracting \"getut.c\" \(2006 characters\)
  1072. sed "s/^X//" >getut.c <<'END_OF_getut.c'
  1073. X/*
  1074. X * getut.c -- read utmp file
  1075. X *
  1076. X * Copyright (C) 1986, 1990  Philip L. Budne
  1077. X *
  1078. X * This file is part of "Phil's Finger Program".
  1079. X *
  1080. X * This program is free software; you can redistribute it and/or modify
  1081. X * it under the terms of the GNU General Public License as published by
  1082. X * the Free Software Foundation; either version 1, or (at your option)
  1083. X * any later version.
  1084. X *
  1085. X */
  1086. X
  1087. X# ifndef lint
  1088. Xstatic char *rcsid = "$Id: getut.c,v 3.0 90/07/06 13:10:58 budd Rel $";
  1089. X# endif /* lint not defined */
  1090. X
  1091. X# include "finger.h"
  1092. X# ifdef USG                /* UTMP_NEEDS_TIME_T? */
  1093. X# include <sys/types.h>            /* for time_t */
  1094. X# endif /* USG defined */
  1095. X# include <utmp.h>
  1096. X# include <stdio.h>
  1097. X
  1098. X# ifdef USER_PROCESS
  1099. X# include <errno.h>
  1100. X# endif /* USER_PROCESS defined */
  1101. X
  1102. X# define UTFILE "/etc/utmp"
  1103. X# define MAXNAME 100
  1104. X
  1105. XLOCAL char utfile[MAXNAME] = UTFILE;
  1106. XLOCAL FILE *f = NULL;
  1107. X
  1108. Xvoid setutent() {
  1109. X    if( f == NULL )
  1110. X    f = fopen( utfile, "r" );
  1111. X    else
  1112. X    rewind( f );
  1113. X} /* setutent */
  1114. X
  1115. Xvoid endutent() {
  1116. X    if( f != NULL )
  1117. X    fclose( f );
  1118. X} /* endutent */
  1119. X
  1120. Xvoid utmpname( file )
  1121. Xchar *file;
  1122. X{
  1123. X    endutent();
  1124. X    strcpy(utfile, file);
  1125. X} /* utmpname */
  1126. X
  1127. Xstruct utmp *getutent() {
  1128. X    static struct utmp ut;
  1129. X    if( f == NULL ) {
  1130. X    setutent();
  1131. X    if( f == NULL )
  1132. X        return( NULL );
  1133. X    }
  1134. X
  1135. X    while( fread(&ut, sizeof( ut ), 1, f) == 1 ) {
  1136. X# ifdef USER_PROCESS
  1137. X    if( ut.ut_type == USER_PROCESS
  1138. X       && (kill( ut.ut_pid, 0 ) == 0 || errno == EPERM ) )
  1139. X# endif /* USER_PROCESS defined */
  1140. X        return( &ut );
  1141. X    }
  1142. X    rewind( f );
  1143. X    return( NULL );
  1144. X} /* getutent */
  1145. X
  1146. X/*
  1147. X *    not implemented:
  1148. X *
  1149. X *    void pututline( struct utmp *u );
  1150. X *        (uses direct write(2))
  1151. X *    struct utmp *getutline( struct utmp *line )
  1152. X *        find entry with matching ut->line
  1153. X *    struct utmp *getutid( struct utmp *id )
  1154. X *        find entry with matching ut->type (!!)
  1155. X *        (RUN_LVL, BOOT_TIME, OLD_TIME, NEW_TIME)
  1156. X *        if one of (INIT_PROCESS, LOGIN_PROCESS, USER_PROCESS
  1157. X *        or DEAD_PROCESS) ut_id must mach also.
  1158. X */
  1159. X
  1160. X/*
  1161. X * Local variables:
  1162. X * comment-column: 40
  1163. X * End:
  1164. X */
  1165. END_OF_getut.c
  1166. if test 2006 -ne `wc -c <getut.c`; then
  1167.     echo shar: \"getut.c\" unpacked with wrong size!
  1168. fi
  1169. # end of overwriting check
  1170. fi
  1171. if test -f kmem.c -a "${1}" != "-c" ; then 
  1172.   echo shar: Will not over-write existing file \"kmem.c\"
  1173. else
  1174. echo shar: Extracting \"kmem.c\" \(3486 characters\)
  1175. sed "s/^X//" >kmem.c <<'END_OF_kmem.c'
  1176. X/*
  1177. X * kmem.c -- interact with /dev/kmem, /dev/mem etc.
  1178. X *
  1179. X * Copyright (C) 1986, 1990  Philip L. Budne
  1180. X *
  1181. X * This file is part of "Phil's Finger Program".
  1182. X *
  1183. X * This program is free software; you can redistribute it and/or modify
  1184. X * it under the terms of the GNU General Public License as published by
  1185. X * the Free Software Foundation; either version 1, or (at your option)
  1186. X * any later version.
  1187. X *
  1188. X */
  1189. X
  1190. X# ifndef lint
  1191. Xstatic char *rcsid = "$Id: kmem.c,v 3.0 90/07/06 13:11:09 budd Rel $";
  1192. X# endif /* lint not defined */
  1193. X
  1194. X# include "finger.h"
  1195. X# if Umax != 42
  1196. X# include <sys/types.h>
  1197. X# include "kmem.h"
  1198. X# include "args.h"            /* sw_debug */
  1199. X
  1200. X/* # define DEBUG            /**/
  1201. X
  1202. X# ifdef sun
  1203. X# include "info.h"            /* info_[r]consdev */
  1204. Xextern struct info I;            /* namelist values from names.c */
  1205. X
  1206. X# include <sys/stat.h>            /* to stat /dev/console */
  1207. XGLOBAL dev_t consdev;
  1208. XGLOBAL dev_t rconsdev;
  1209. XGLOBAL dev_t dev_console;
  1210. X# endif /* sun defined */
  1211. X
  1212. XGLOBAL FTYPE kmem;            /* fd for /dev/kmem */
  1213. X# if SunOS < 400
  1214. XGLOBAL FTYPE mem;            /* fd for /dev/mem */
  1215. X# ifdef SWAP_DEVICE
  1216. XGLOBAL FTYPE drum;            /* fd for /dev/drum */
  1217. X# endif /* SWAP_DEVICE defined */
  1218. X# else  /* not SunOS < 400 */
  1219. X# include <sys/file.h>            /* O_RDONLY */
  1220. X# include <stdio.h>            /* NULL */
  1221. X# endif /* not SunOS < 400 */
  1222. X
  1223. X
  1224. XGLOBAL int ini_kmem() {
  1225. X# ifdef sun
  1226. X    struct stat stb;
  1227. X# endif /* sun defined */
  1228. X
  1229. X# if SunOS >= 400
  1230. X    if( (kmem = kvm_open( NULL, NULL, NULL, O_RDONLY, "finger" )) == NULL ) {
  1231. X    perror("kvm_open");
  1232. X    return( FALSE );
  1233. X    }
  1234. X# else  /* not SunOS >= 400 */
  1235. X    if( ISBADFILE( (kmem = OPEN("/dev/kmem")) ) ) {
  1236. X    perror("/dev/kmem");
  1237. X     kmem = BADFILE;     
  1238. X    return( FALSE );
  1239. X    }
  1240. X
  1241. X    if( ISBADFILE( (mem = OPEN("/dev/mem")) ) ) {
  1242. X    perror("/dev/mem");
  1243. X    CLOSE(kmem);
  1244. X    kmem = BADFILE;
  1245. X    return( FALSE );
  1246. X    }
  1247. X
  1248. X# ifdef SWAP_DEVICE
  1249. X    if( ISBADFILE( (drum = OPEN( SWAP_DEVICE )) ) ) {
  1250. X    perror(SWAP_DEVICE);
  1251. X    CLOSE(kmem);
  1252. X    CLOSE(mem);
  1253. X     kmem = BADFILE;
  1254. X     return( FALSE );
  1255. X    }
  1256. X# endif /* SWAP_DEVICE defined */
  1257. X# endif /* not SunOS >= 400 */
  1258. X
  1259. X    if( !readnames() )            /* read in info struct */
  1260. X    return( FALSE );
  1261. X
  1262. X# ifdef sun
  1263. X    KMEMREAD(I.info_consdev,  &consdev,  sizeof(consdev));
  1264. X    KMEMREAD(I.info_rconsdev, &rconsdev, sizeof(rconsdev));
  1265. X    if( stat("/dev/console", &stb ) == 0 )
  1266. X    dev_console = stb.st_rdev;
  1267. X    else
  1268. X    dev_console = 0xffff;        /* makedev(255,255) */
  1269. X# ifdef DEBUGSW
  1270. X    if( sw_debug )
  1271. X    printf("consdev %#x rconsdev %#x /dev/console %#x\n",
  1272. X           consdev, rconsdev, dev_console );
  1273. X# endif /* DEBUGSW defined */
  1274. X# endif /* sun defined */
  1275. X
  1276. X    return( TRUE );
  1277. X} /* ini_kmem */
  1278. X
  1279. X# if SunOS < 400            /* anything but SunOS 4.x */
  1280. XGLOBAL int kread(f, pos, buf, count)
  1281. XFTYPE f;
  1282. Xint count;
  1283. Xunsigned long pos;            /* caddr_t? */
  1284. Xchar *buf;
  1285. X{
  1286. X    int cc;
  1287. X# ifdef DEBUG
  1288. X    char *name;
  1289. X
  1290. X    if( f == mem )
  1291. X    name = " mem";
  1292. X    else if( f == kmem )
  1293. X    name = "kmem";
  1294. X    else if( f == drum )
  1295. X    name = "drum";
  1296. X    else
  1297. X    name = "??";
  1298. X# endif /* DEBUG defined */
  1299. X
  1300. X    if( SEEK(f, pos, 0) == -1 ) {
  1301. X        perror("seek");
  1302. X    cc = -1;
  1303. X    }
  1304. X    else 
  1305. X    cc = READ(f, buf, count);
  1306. X
  1307. X# if BUFIO
  1308. X    if( cc > 0 )
  1309. X    cc *= count;
  1310. X# endif /* BUFIO */
  1311. X
  1312. X# ifdef DEBUG
  1313. X    printf("kread: %s@%08x %d(%d) chars\n",
  1314. X       name,
  1315. X       pos,
  1316. X       count,
  1317. X       cc);
  1318. X# endif /* DEBUG defined */
  1319. X
  1320. X    if( cc == -1 ) {
  1321. X# ifdef DEBUG
  1322. X    perror("read");
  1323. X# endif /* DEBUG defined */
  1324. X    return( FALSE );
  1325. X    } /* bad return */
  1326. X    return( TRUE );
  1327. X} /* kread */
  1328. X# endif /* SunOS < 400 */
  1329. X
  1330. X# endif /* Umax != 42 */
  1331. X
  1332. X/*
  1333. X * Local variables:
  1334. X * comment-column: 40
  1335. X * End:
  1336. X */
  1337. END_OF_kmem.c
  1338. if test 3486 -ne `wc -c <kmem.c`; then
  1339.     echo shar: \"kmem.c\" unpacked with wrong size!
  1340. fi
  1341. # end of overwriting check
  1342. fi
  1343. if test -f lastlog.c -a "${1}" != "-c" ; then 
  1344.   echo shar: Will not over-write existing file \"lastlog.c\"
  1345. else
  1346. echo shar: Extracting \"lastlog.c\" \(1815 characters\)
  1347. sed "s/^X//" >lastlog.c <<'END_OF_lastlog.c'
  1348. X/*
  1349. X * lastlog.c - get time and location of last login
  1350. X *
  1351. X * Copyright (C) 1986, 1990  Philip L. Budne
  1352. X *
  1353. X * This file is part of "Phil's Finger Program".
  1354. X *
  1355. X * This program is free software; you can redistribute it and/or modify
  1356. X * it under the terms of the GNU General Public License as published by
  1357. X * the Free Software Foundation; either version 1, or (at your option)
  1358. X * any later version.
  1359. X *
  1360. X */
  1361. X
  1362. X# ifndef lint
  1363. Xstatic char *rcsid = "$Id: lastlog.c,v 3.0 90/07/06 13:11:14 budd Rel $";
  1364. X# endif /* lint not defined */
  1365. X
  1366. X# include "finger.h"
  1367. X# ifdef LASTLOG
  1368. X# include <sys/types.h>
  1369. X# include <ctype.h>
  1370. X# include <lastlog.h>
  1371. X
  1372. X# ifndef LLPATH
  1373. X# define LLPATH "/usr/adm/lastlog"
  1374. X# endif /* LLPATH not defined */
  1375. X
  1376. XLOCAL llfile = -1;
  1377. X
  1378. XGLOBAL void llopen() {
  1379. X    if( llfile < 0 )
  1380. X    llfile = open(LLPATH, 0);
  1381. X    else
  1382. X    lseek( llfile, 0L, 0 );
  1383. X} /* llopen */
  1384. X
  1385. XGLOBAL void llclose() {
  1386. X    if( llfile >= 0 )
  1387. X    close( llfile );
  1388. X} /* llclose */
  1389. X
  1390. XGLOBAL BOOL lltime( uid, location, time, host )
  1391. Xshort uid;
  1392. Xchar *location;
  1393. Xtime_t *time;
  1394. Xint *host;
  1395. X{
  1396. X    struct lastlog ll;
  1397. X
  1398. X    if( llfile < 0 )
  1399. X    return( FALSE );
  1400. X
  1401. X    lseek( llfile, uid * sizeof( ll ), 0 );
  1402. X    if( read(llfile, &ll, sizeof( ll ) ) != sizeof( ll ) )
  1403. X    return( FALSE );
  1404. X
  1405. X    *time = ll.ll_time;            /* return time of login */
  1406. X    if( ll.ll_host[0] != EOS ) {
  1407. X    *host = TRUE;
  1408. X    strzcpy(location, ll.ll_host,
  1409. X        sizeof( ll.ll_host ) );    /* copy fixed len */
  1410. X
  1411. X    if( isdigit(*location) )
  1412. X        checkhost( location, sizeof( location ) ); /* hack octets */
  1413. X    undomain( location, 0 );     /* remove domains, but not prefixes */
  1414. X    HZUP( location );        /* upper caseify */
  1415. X    }
  1416. X    else {
  1417. X    *host = FALSE;
  1418. X    strzcpy(location, ll.ll_line, sizeof( ll.ll_line ) );
  1419. X    }
  1420. X    return( TRUE );
  1421. X} /* lltime */
  1422. X# endif /* LASTLOG defined */
  1423. X/*
  1424. X * Local variables:
  1425. X * comment-column: 40
  1426. X * End:
  1427. X */
  1428. END_OF_lastlog.c
  1429. if test 1815 -ne `wc -c <lastlog.c`; then
  1430.     echo shar: \"lastlog.c\" unpacked with wrong size!
  1431. fi
  1432. # end of overwriting check
  1433. fi
  1434. if test -f luser.h -a "${1}" != "-c" ; then 
  1435.   echo shar: Will not over-write existing file \"luser.h\"
  1436. else
  1437. echo shar: Extracting \"luser.h\" \(1888 characters\)
  1438. sed "s/^X//" >luser.h <<'END_OF_luser.h'
  1439. X/*
  1440. X * luser.h -- per utmp entry information (December 1985)
  1441. X *
  1442. X * Copyright (C) 1986, 1990  Philip L. Budne
  1443. X *
  1444. X * This file is part of "Phil's Finger Program".
  1445. X *
  1446. X * This program is free software; you can redistribute it and/or modify
  1447. X * it under the terms of the GNU General Public License as published by
  1448. X * the Free Software Foundation; either version 1, or (at your option)
  1449. X * any later version.
  1450. X *
  1451. X */
  1452. X
  1453. X# define LUSER_RCSID "$Id: luser.h,v 3.0 90/07/06 13:11:17 budd Rel $"
  1454. X
  1455. X# define ULEN 9            /* user length */
  1456. X# define TLEN 9            /* tty (line) length */
  1457. X# define HLEN 40        /* host name length */
  1458. X
  1459. Xtypedef struct luser {        /* per-login/tty information */
  1460. X    /* use pointers for user, line, host? */
  1461. X    char u_user[ULEN];        /* user name */
  1462. X    char u_line[TLEN];        /* tty name */
  1463. X    char u_host[HLEN];        /* fn host (if any) */
  1464. X    time_t u_time;        /* login time */
  1465. X    time_t u_idle;        /* time of last terminal act. */
  1466. X    struct person *u_person;    /* personal information */
  1467. X    struct luser *u_left, *u_right; /* children for btree */
  1468. X    unsigned short u_flags;    /* flagies */
  1469. X    dev_t u_ttydev;        /* device number of tty */
  1470. X    struct pr *u_command, *u_daemonp; /* "current" process, daemon process */
  1471. X    struct daemon *u_daemon;    /* daemon if any */
  1472. X# ifdef Umax
  1473. X    long  u_ttyaddr;        /* inet addr of annex/rdp tty */
  1474. X    short u_ttytype;        /* device type of annex/rdp tty */
  1475. X    short u_ttynum;        /* device number of annex/rdp tty */
  1476. X# endif /* Umax defined */
  1477. X    struct switches u_sw;    /* per luser arg flags (from selector!) */
  1478. X} LUSER;
  1479. X
  1480. X# define LTREE LUSER
  1481. X
  1482. X/* in u_flags */
  1483. X# define U_NOWRITE 001        /* msg n */
  1484. X# define U_BIFF       002        /* biff y */
  1485. X# define U_NLI     004        /* not logged in */
  1486. X# define U_FOUND   010        /* found logged in */
  1487. X# define U_HUNGRY  020        /* hungry y */
  1488. X# define U_BADTTY  040        /* could not stat tty */
  1489. X
  1490. X/*
  1491. X * Local variables:
  1492. X * comment-column: 32
  1493. X * End:
  1494. X */
  1495. END_OF_luser.h
  1496. if test 1888 -ne `wc -c <luser.h`; then
  1497.     echo shar: \"luser.h\" unpacked with wrong size!
  1498. fi
  1499. # end of overwriting check
  1500. fi
  1501. if test -f newmanifest.c -a "${1}" != "-c" ; then 
  1502.   echo shar: Will not over-write existing file \"newmanifest.c\"
  1503. else
  1504. echo shar: Extracting \"newmanifest.c\" \(3484 characters\)
  1505. sed "s/^X//" >newmanifest.c <<'END_OF_newmanifest.c'
  1506. X/*
  1507. X * newmanifest.c -- crock to merge MANIFEST descriptions with file list
  1508. X *
  1509. X * Copyright (C) 1989, 1990  Philip L. Budne
  1510. X *
  1511. X * This file is part of "Phil's Finger Program".
  1512. X *
  1513. X * This program is free software; you can redistribute it and/or modify
  1514. X * it under the terms of the GNU General Public License as published by
  1515. X * the Free Software Foundation; either version 1, or (at your option)
  1516. X * any later version.
  1517. X *
  1518. X */
  1519. X
  1520. X# ifndef lint
  1521. Xstatic char *rcsid = "$Id: newmanifest.c,v 3.0 90/07/06 13:11:25 budd Rel $";
  1522. X# endif /* lint not defined */
  1523. X
  1524. X# include <stdio.h>
  1525. X# include <ctype.h>
  1526. X# include <strings.h>            /* I'm sorry for you if you use USG! */
  1527. X
  1528. X# define MAXFILES 5000            /* seems like plenty */
  1529. X# define MAXSTR 100
  1530. X
  1531. Xstruct file {
  1532. X    char fname[ MAXSTR ];
  1533. X    int archive, found;
  1534. X    char descrip[ MAXSTR ];
  1535. X} files[ MAXFILES ];            /* should use a binary tree. */
  1536. Xint nfiles = 0;
  1537. X
  1538. X# define MANIFEST "MANIFEST"
  1539. X
  1540. Xchar *prog;
  1541. X
  1542. Xint
  1543. Xmain( argc, argv )
  1544. X    int argc;
  1545. X    char *argv[];
  1546. X{
  1547. X    FILE *m;
  1548. X    char line[ 1024 ];
  1549. X    int i;
  1550. X
  1551. X    prog = argv[0];
  1552. X    argc--;
  1553. X    argv++;
  1554. X
  1555. X    if( (m = fopen(MANIFEST, "r")) == NULL ) {
  1556. X    perror( MANIFEST );
  1557. X    }
  1558. X    else {
  1559. X    int skip = 2;
  1560. X
  1561. X    while( fgets( line, sizeof( line ), m ) != NULL )
  1562. X        if( skip > 0 )
  1563. X        skip--;
  1564. X        else {
  1565. X        char *cp, *dp;
  1566. X        if( (cp = index( line, '\n' )) != NULL )
  1567. X            *cp = '\0';
  1568. X        else
  1569. X            fprintf( stderr, "line truncated!!\n" );
  1570. X
  1571. X        cp = line;
  1572. X        if( isspace( *cp ) )
  1573. X            cp++;
  1574. X        if( *cp == '\0' )
  1575. X            continue;
  1576. X
  1577. X        dp = files[ nfiles ].fname;
  1578. X        while( *cp != '\0' && !isspace( *cp ) )
  1579. X            *dp++ = *cp++;
  1580. X        if( dp == files[ nfiles ].fname )
  1581. X            continue;
  1582. X
  1583. X        while( isspace( *cp ) )
  1584. X            cp++;
  1585. X
  1586. X        files[ nfiles ].archive = atoi( cp ); /* who cares!! */
  1587. X        while( isdigit( *cp ) )    /* skip past archive number */
  1588. X            cp++;
  1589. X
  1590. X        while( isspace( *cp ) )    /* skip any whitspace */
  1591. X            cp++;
  1592. X
  1593. X        dp = files[ nfiles ].descrip;
  1594. X        while( *dp++ = *cp++ )    /* save any description */
  1595. X            ;
  1596. X
  1597. X        files[nfiles].found = 0; /* not found yet */
  1598. X        nfiles++;
  1599. X        } /* not skipping */
  1600. X    } /* while */
  1601. X
  1602. X    /* perhaps qsort files[] so we can binary search? */
  1603. X    /* perhaps store in a binary tree so we can insert easily? */
  1604. X    /* don't you wish you used C++?? Looks like line noise to me tho.... */
  1605. X    /* do we really care? how big is this kit anyway??? */
  1606. X
  1607. X    while( argc > 0 ) {
  1608. X    for( i = 0; i < nfiles; i++ )    /* awful linear search */
  1609. X        if( strcmp( files[i].fname, argv[0]) == 0 ) {
  1610. X        files[i].found = 1;    /* now can see (was blind) */
  1611. X        break;
  1612. X        }
  1613. X    if( i == nfiles ) {        /* not found in MANIFEST? */
  1614. X        strcpy( files[i].fname, argv[0] ); /* add it to list */
  1615. X        strcpy( files[i].descrip, "" ); /* sorry. */
  1616. X        files[i].archive = 999;    /* very silly kit number */
  1617. X        files[i].found = -1;    /* flag as just added */
  1618. X        nfiles++;
  1619. X        fprintf( stderr, "adding %s\n", argv[0] );
  1620. X    } /* not previously in list */
  1621. X    argc--;
  1622. X    argv++;
  1623. X    } /* while argc */
  1624. X
  1625. X    /* I'm so lazy, should fopen output file, not use stdout! */
  1626. X    puts("this was created by newmanifest.");
  1627. X    puts("   File Name        Archive #    Description");
  1628. X
  1629. X    /* less than perfect formatting. will be re-read by makekit soon */
  1630. X    for( i = 0; i < nfiles; i++ )
  1631. X    if( files[i].found != 0 )    /* found in argv[] */
  1632. X        printf(" %-25s %d\t%s\n",
  1633. X           files[ i ].fname,
  1634. X           files[ i ].archive,
  1635. X           files[ i ].descrip );
  1636. X    else                /* not found... */
  1637. X        fprintf( stderr, "flushing %s\n", files[i].fname );
  1638. X    return( 0 );            /* Be ANSI */
  1639. X} /* main */
  1640. END_OF_newmanifest.c
  1641. if test 3484 -ne `wc -c <newmanifest.c`; then
  1642.     echo shar: \"newmanifest.c\" unpacked with wrong size!
  1643. fi
  1644. # end of overwriting check
  1645. fi
  1646. if test -f nttyloc.5 -a "${1}" != "-c" ; then 
  1647.   echo shar: Will not over-write existing file \"nttyloc.5\"
  1648. else
  1649. echo shar: Extracting \"nttyloc.5\" \(2000 characters\)
  1650. sed "s/^X//" >nttyloc.5 <<'END_OF_nttyloc.5'
  1651. X.\" -*-nroff-*-
  1652. X.\" $Id: nttyloc.5,v 3.0 90/07/06 13:11:27 budd Rel $
  1653. X.\" Copyright (c) 1987, 1990  Philip L. Budne
  1654. X.TH NTTYLOC 5 "14 June 1988"
  1655. X.UC 4
  1656. X.SH NAME
  1657. Xnttyloc \- new finger ttyloc file format
  1658. X.SH DESCRIPTION
  1659. XThe
  1660. X.I nttyloc
  1661. Xfile describes the physical location and type of each terminal
  1662. Xline on the system.  This file is accessed via the
  1663. X.I readttyloc (3)
  1664. Xand
  1665. X.I findttyloc (3)
  1666. Xfunctions.
  1667. X.PP
  1668. XIf the first non whitespace character on a line is a poundsign (#),
  1669. Xthe line is ignored. The first field is the line type.  The keyword
  1670. X.I ttyloc
  1671. Xsignifies a hardwired line not suitable for mauling by an idle terminal
  1672. Xmauling daemon (none exist yet) while
  1673. X.I hardwire
  1674. Xsignifies one that is.
  1675. X.I dialup
  1676. Xmeans that the line is directly connected to a modem, data switch,
  1677. Xor other ephemeral terminal location.
  1678. X.I random
  1679. Xcan be used when the line is not connected.
  1680. X.PP
  1681. XThe second field is the ``short'' location, displayed by
  1682. X.IR finger (1)
  1683. Xwhen the user has created a file named ttyloc\fIhostname_tty\fR
  1684. Xin /usr/spool/ttyloc since login using the
  1685. X.IR ttyloc (1)
  1686. Xprogram.  The third field is the ``long'' location displayed when
  1687. Xthere is no current file in /usr/spool/ttyloc.
  1688. XBoth the short fields can be many words long (or empty) if quoted
  1689. Xwith single or double quote marks.
  1690. X
  1691. X.PP
  1692. XSome examples:
  1693. X.PP
  1694. X.ta \w'random\ \ 'u +\w'console\ \ 'u +\w'VA3451\ \ 'u +.7i
  1695. X.nf
  1696. X# bu-cs /etc/nttyloc
  1697. Xttyloc    console    CTY     "BU-CS console"
  1698. Xdialup    tty00    VA3451    "IMP (VA3451)"
  1699. Xrandom    tty01    MUX    MUX
  1700. Xhard    tty02    Opr    "Operations Central (x2089)"
  1701. Xttyloc    tty03    3b5    "3b5 ersatz ethernet"
  1702. Xdialup    tty08    ""    "Campus Terminal Network"
  1703. Xttyloc    ttya    qms    "Terminal port A (QMS 1200)"
  1704. X.fi
  1705. X.SH FILES
  1706. X.ta \w'/usr/spool/ttyloc\ \ 'u
  1707. X.nf
  1708. X/etc/nttyloc    system default ttylocs (line type, tty, short/long)
  1709. X/etc/ttyloc    system default ttylocs old format (tty, long)
  1710. X/etc/ttys    used under 4.3 for last ditch (ttytype/comment)
  1711. X/usr/spool/ttyloc    user set ttyloc files
  1712. X.fi
  1713. X.SH "SEE ALSO"
  1714. Xfinger(1), ttyask(1), readttylocfile(3)
  1715. X.SH AUTHOR
  1716. XPhilip L. Budne
  1717. END_OF_nttyloc.5
  1718. if test 2000 -ne `wc -c <nttyloc.5`; then
  1719.     echo shar: \"nttyloc.5\" unpacked with wrong size!
  1720. fi
  1721. # end of overwriting check
  1722. fi
  1723. if test -f string.c -a "${1}" != "-c" ; then 
  1724.   echo shar: Will not over-write existing file \"string.c\"
  1725. else
  1726. echo shar: Extracting \"string.c\" \(2753 characters\)
  1727. sed "s/^X//" >string.c <<'END_OF_string.c'
  1728. X/*
  1729. X * string.c -- common string routines for finger (December 1985)
  1730. X *
  1731. X * Copyright (C) 1986, 1990  Philip L. Budne
  1732. X *
  1733. X * This file is part of "Phil's Finger Program".
  1734. X *
  1735. X * This program is free software; you can redistribute it and/or modify
  1736. X * it under the terms of the GNU General Public License as published by
  1737. X * the Free Software Foundation; either version 1, or (at your option)
  1738. X * any later version.
  1739. X *
  1740. X */
  1741. X
  1742. X# ifndef lint
  1743. Xstatic char *rcsid = "$Id: string.c,v 3.0 90/07/06 13:11:46 budd Rel $";
  1744. X# endif /* lint not defined */
  1745. X
  1746. X# include <ctype.h>            /* for isxxx */
  1747. X# include <stdio.h>            /* for NULL */
  1748. X# include <strings.h>            /* for strcpy() */
  1749. X# include "finger.h"
  1750. X# include "upper.h"            /* uppercase[] */
  1751. X
  1752. XGLOBAL char *strip( s )
  1753. Xregister char *s;
  1754. X{
  1755. X    register char *cp;
  1756. X
  1757. X    for( cp = s; isprint( *cp ); cp++ )    /* skip printing chars */
  1758. X    ;
  1759. X    *cp = EOS;                /* tie off after printables */
  1760. X
  1761. X    while( cp > s )            /* backup */
  1762. X    if( isspace( *(cp - 1) ) )    /* is previous a space? */
  1763. X        cp--;            /* yes, keep going */
  1764. X    else
  1765. X        break;
  1766. X    *cp = EOS;                /* tie off before spaces */
  1767. X
  1768. X    for( cp = s; isspace( *cp ); cp++ )    /* start at top */
  1769. X    ;                /* skipping spaces */
  1770. X
  1771. X    return( cp );            /* return remainder */
  1772. X} /* strip */
  1773. X
  1774. XGLOBAL void cleanup( s )    /* strip off leading white, trailing crud */
  1775. Xregister char *s;        /* in place */
  1776. X{
  1777. X    register char *cp;
  1778. X
  1779. X    for( cp = s; isprint( *cp ); cp++ ) ; /* cut off any crud.. */
  1780. X    *cp = EOS;
  1781. X
  1782. X    for( cp = s; *cp != EOS && isspace( *cp ); cp++ ); /* trim leading white */
  1783. X
  1784. X    if( cp != s )        /* leading white? */
  1785. X    if( *cp == EOS )
  1786. X        *s = EOS;        /* empty string!! */
  1787. X    else
  1788. X        strcpy(s, cp);    /* copy backwards to remove leading white */
  1789. X} /* cleanup */
  1790. X
  1791. XGLOBAL char *zup( s )        /* blast in place to upper */
  1792. Xchar *s;
  1793. X{
  1794. X    register char *cp;
  1795. X    for( cp = s; *cp != NULL; cp++ )
  1796. X        *cp = uppercase[ *cp & 0177 ];
  1797. X
  1798. X    return( s );
  1799. X} /* zup */
  1800. X
  1801. XGLOBAL char *strzcpy(dest, src, count)    /* non-nul terminated src, max length */
  1802. Xregister char *dest, *src;
  1803. Xregister int count;
  1804. X{
  1805. X    while( count-- > 0  &&  *src != EOS )
  1806. X    *dest++ = *src++;
  1807. X
  1808. X    *dest = EOS;
  1809. X    return( dest );
  1810. X} /* strzcpy */
  1811. X
  1812. X
  1813. XGLOBAL char *strupcpy(dest, src)    /* copy and uppercasify */
  1814. Xregister char *src, *dest;
  1815. X{
  1816. X    register int c;
  1817. X
  1818. X    do
  1819. X    *dest++ = uppercase[ (c = *src++ & 0177) ];
  1820. X    while( c != EOS );
  1821. X    return( dest );
  1822. X} /* strupcpy */
  1823. X
  1824. XGLOBAL char *savestr( s )
  1825. Xchar *s;
  1826. X{
  1827. X    char *d;
  1828. X
  1829. X    if( s == NULL )
  1830. X    return( NULL );            /* note: NOT "" (see alias copy loop) */
  1831. X                    /* in args.c */
  1832. X
  1833. X    if( (d = malloc( strlen( s ) + 1 )) == NULL ) {
  1834. X    fprintf(stderr, "?Savestr failed for '%s'\n", s);
  1835. X    exit( 1 );
  1836. X    }
  1837. X    return( strcpy(d, s) );
  1838. X} /* savestr */
  1839. X
  1840. X/*
  1841. X * Local variables:
  1842. X * comment-column: 40
  1843. X * End:
  1844. X */
  1845. END_OF_string.c
  1846. if test 2753 -ne `wc -c <string.c`; then
  1847.     echo shar: \"string.c\" unpacked with wrong size!
  1848. fi
  1849. # end of overwriting check
  1850. fi
  1851. if test -f switch.h -a "${1}" != "-c" ; then 
  1852.   echo shar: Will not over-write existing file \"switch.h\"
  1853. else
  1854. echo shar: Extracting \"switch.h\" \(2349 characters\)
  1855. sed "s/^X//" >switch.h <<'END_OF_switch.h'
  1856. X/*
  1857. X * switch.h -- switch definitions for finger
  1858. X *
  1859. X * Copyright (C) 1987, 1990  Philip L. Budne
  1860. X *
  1861. X * This file is part of "Phil's Finger Program".
  1862. X *
  1863. X * This program is free software; you can redistribute it and/or modify
  1864. X * it under the terms of the GNU General Public License as published by
  1865. X * the Free Software Foundation; either version 1, or (at your option)
  1866. X * any later version.
  1867. X *
  1868. X */
  1869. X
  1870. X# define SWITCH_RCSID "$Id: switch.h,v 3.0 90/07/06 13:11:50 budd Rel $"
  1871. X
  1872. X/* string, unique length, action(routine in args.c), help */
  1873. XSWITCH("age",        1,set_age,    "display job age rather than idle time")
  1874. XSWITCH("berkeley",  1,set_berkeley,"user names imply /plan/whois")
  1875. X# ifdef DEBUGSW
  1876. XSWITCH("debug",        1,set_debug,"enable debug output")
  1877. X# endif /* DEBUGSW defined */
  1878. X# ifdef notdef
  1879. XSWITCH("fields",    2,set_fields,"output for awk /fields[:sep] sets FS")
  1880. X# endif /* notdef defined */
  1881. XSWITCH("follow",    2,set_follow,"let finger do the walking (follow .forward)")
  1882. XSWITCH("help",        1,display_help,"display help (you are looking at it)")
  1883. XSWITCH("its",        1,set_its,"format output more like MIT-ITS finger")
  1884. XSWITCH("location",  1,set_location,"ignore user set ttylocs")
  1885. XSWITCH("mail-check",3,set_mail,    "show information about mail file")
  1886. XSWITCH("match-user",1,set_match,"match on user name only")
  1887. X# ifdef INQUIRE
  1888. XSWITCH("noinquire", 1,set_noinquire,"prohibit using inquire database")
  1889. X# endif /* INQUIRE defined */
  1890. XSWITCH("noplan",    3,set_noplan,"prohibit plan display")
  1891. X# ifdef SAVED_NLIST
  1892. XSWITCH("nosave-nlist",3,set_nosave,"prohibit saving of /vmunix namelist file")
  1893. X# endif /* SAVED_NLIST defined */
  1894. XSWITCH("output-idle",1,set_output,"show time since last output to terminal")
  1895. XSWITCH("plan-check",1,set_plan,    "show plan files")
  1896. XSWITCH("pid",        2,set_pid,    "show process id")
  1897. X# ifdef SAVED_NLIST
  1898. XSWITCH("read-nlist",1,set_read, "force reading of /vmunix namelist file")
  1899. X# endif /* SAVED_NLIST defined */
  1900. XSWITCH("short",        1,set_jobs,    "short form (same as /jobs)")
  1901. XSWITCH("state",        1,set_state,"display process state in place of idle time")
  1902. XSWITCH("user-match",1,set_match,"alias for /match-user")
  1903. XSWITCH("whois",        1,set_whois,"display personal info (whois command)")
  1904. XSWITCH("whoj",        4,set_jobs, "alias for /short")
  1905. XSWITCH("version",   1,display_version, "display version")
  1906. X
  1907. X/*
  1908. X * Local variables:
  1909. X * comment-column: 40
  1910. X * End:
  1911. X */
  1912. END_OF_switch.h
  1913. if test 2349 -ne `wc -c <switch.h`; then
  1914.     echo shar: \"switch.h\" unpacked with wrong size!
  1915. fi
  1916. # end of overwriting check
  1917. fi
  1918. if test -f syms.h -a "${1}" != "-c" ; then 
  1919.   echo shar: Will not over-write existing file \"syms.h\"
  1920. else
  1921. echo shar: Extracting \"syms.h\" \(2245 characters\)
  1922. sed "s/^X//" >syms.h <<'END_OF_syms.h'
  1923. X/*
  1924. X * syms.h -- names to lookup via nlist
  1925. X *
  1926. X * Copyright (C) 1986, 1990  Philip L. Budne
  1927. X *
  1928. X * This file is part of "Phil's Finger Program".
  1929. X *
  1930. X * This program is free software; you can redistribute it and/or modify
  1931. X * it under the terms of the GNU General Public License as published by
  1932. X * the Free Software Foundation; either version 1, or (at your option)
  1933. X * any later version.
  1934. X *
  1935. X */
  1936. X
  1937. X# define SYMS_RCSID "$Id: syms.h,v 3.0 90/07/06 13:11:53 budd Rel $"
  1938. X
  1939. X# ifndef _FINGER_H_
  1940. X# include "finger.h"
  1941. X# endif /* _FINGER_H_ not defined */
  1942. X
  1943. X# ifndef _SYMS_H_
  1944. X# define _SYMS_H_
  1945. X# ifdef sgi
  1946. X# define HAVE_KERNEL_MAGIC
  1947. X# endif /* sgi defined */
  1948. X# ifndef USG
  1949. X# define HAVE_VERSION
  1950. X# endif /* USG not defined */
  1951. X# endif /* _SYMS_H_ not defined */
  1952. X
  1953. X/*
  1954. X *    First argument is string for nlist.
  1955. X *    Second argument is string for nlist on COFF systems
  1956. X *    Third is member name for Info struct
  1957. X */
  1958. X
  1959. X    SYM("_proc","proc",proc)        /* process table (or pointer) */
  1960. X# if SunOS < 410
  1961. X    SYM("_u","u",u)            /* u struct (for pause sleep addr) */
  1962. X# else  /* not SunOS < 410 */
  1963. X    SYM("_kernelmap","u",u)            /* u struct (for pause sleep addr) */
  1964. X# endif /* not SunOS < 410 */
  1965. X
  1966. X# ifdef USG
  1967. X    SYM("_v","v",v)            /* sys/var.h var struct */
  1968. X# ifdef STREAMS
  1969. X    SYM("_pollwait","pollwait",pollwait) /* poll(2) sleep address */
  1970. X# endif /* STREAMS defined */
  1971. X# else  /* USG not defined */
  1972. X    SYM("_nproc","nproc",nproc)        /* size of process table */
  1973. X    SYM("_version","version",version)    /* version/build id string */
  1974. X    SYM("_selwait","selwait",selwait)    /* select(2) sleep address */
  1975. X# endif /* USG not defined */
  1976. X
  1977. X# ifdef sun
  1978. X    SYM("_consdev","consdev",consdev)    /* console device */
  1979. X    SYM("_rconsdev","rconsdev",rconsdev) /* redirected console? */
  1980. X# endif /* sun defined */
  1981. X
  1982. X# ifdef sgi
  1983. X    SYM("_end","end",end)        /* label at end of bss */
  1984. X    SYM("_kernel_magic","kernel_magic",kernel_magic) /* value of _end */
  1985. X# endif /* sgi defined */
  1986. X
  1987. X# ifdef NEED_USRPT
  1988. X    SYM("_usrpt","usrpt",usrpt)
  1989. X    SYM("_Usrptmap","Usrptmap",Usrptmap)
  1990. X# endif /* NEED_USRPT defined */
  1991. X
  1992. X# ifdef ibm032                /* RT/AOS4.3 */
  1993. X    SYM("_procSIZE","procSIZE",procSIZE)
  1994. X    SYM("_userSIZE","userSIZE",userSIZE)
  1995. X# endif /* ibm032 defined */
  1996. X
  1997. X/*
  1998. X * Local variables:
  1999. X * comment-column: 40
  2000. X * End:
  2001. X */
  2002. END_OF_syms.h
  2003. if test 2245 -ne `wc -c <syms.h`; then
  2004.     echo shar: \"syms.h\" unpacked with wrong size!
  2005. fi
  2006. # end of overwriting check
  2007. fi
  2008. if test -f ttyloc.1 -a "${1}" != "-c" ; then 
  2009.   echo shar: Will not over-write existing file \"ttyloc.1\"
  2010. else
  2011. echo shar: Extracting \"ttyloc.1\" \(3045 characters\)
  2012. sed "s/^X//" >ttyloc.1 <<'END_OF_ttyloc.1'
  2013. X.\" -*-nroff-*-
  2014. X.\" $Id: ttyloc.1,v 3.0 90/07/06 13:12:00 budd Rel $
  2015. X.\" Copyright (c) 1987, 1990  Philip L. Budne
  2016. X.TH TTYLOC 1 "14 June 1988"
  2017. X.UC 4
  2018. X.SH NAME
  2019. Xttyloc, ttyfrob, ttyask, ttyplace, ttycycle, ttyrandom \- set user console location for finger
  2020. X.SH SYNOPSIS
  2021. X.B ttyloc
  2022. X[
  2023. X.I text
  2024. X]
  2025. X
  2026. X.B ttyfrob
  2027. X.I terminal
  2028. X[
  2029. X.I text
  2030. X]
  2031. X
  2032. X.B ttyask
  2033. X[
  2034. X.B -c
  2035. X] [
  2036. X.B -p
  2037. X] [
  2038. X.B -r
  2039. X] [
  2040. X.B -f
  2041. X.I file
  2042. X] [
  2043. X.B -t
  2044. X.I time
  2045. X] [
  2046. X-h
  2047. X]
  2048. X
  2049. X.B ttyplace
  2050. X[
  2051. X.B -a
  2052. X] [
  2053. X.B -c
  2054. X] [
  2055. X.B -r
  2056. X] [
  2057. X.B -f
  2058. X.I file
  2059. X]
  2060. X.I place
  2061. X
  2062. X.B ttycycle
  2063. X[
  2064. X.B -a
  2065. X] [
  2066. X.B -p
  2067. X] [
  2068. X.B -r
  2069. X] [
  2070. X.B -f
  2071. X.I file
  2072. X] [
  2073. X.B -t
  2074. X.I time
  2075. X]
  2076. X
  2077. X.B ttycycle
  2078. X[
  2079. X.B -a
  2080. X] [
  2081. X.B -p
  2082. X] [
  2083. X.B -r
  2084. X] [
  2085. X.B -f
  2086. X.I file
  2087. X] [
  2088. X.B -t
  2089. X.I time
  2090. X]
  2091. X
  2092. X.B ttyrandom
  2093. X[
  2094. X.B -a
  2095. X] [
  2096. X.B -c
  2097. X] [
  2098. X.B -p
  2099. X] [
  2100. X.B -f
  2101. X.I file
  2102. X] [
  2103. X.B -t
  2104. X.I time
  2105. X]
  2106. X
  2107. X.SH DESCRIPTION
  2108. X.I Ttyloc
  2109. Xsets the
  2110. X.I finger
  2111. Xterminal location string for the current terminal login.
  2112. XIf the user does not run
  2113. X.I ttyloc
  2114. Xa default location is displayed. Running
  2115. X.I ttyloc
  2116. Xwith no arguments clears the user set location string.
  2117. X
  2118. X.I Ttyfrob
  2119. Xsets the location string for the specified terminal.
  2120. XThe user must own the device or be the super user.
  2121. X
  2122. X.I Ttyask
  2123. Xis a front end for ttyloc, useful in your
  2124. X.I .login
  2125. Xor
  2126. X.I .profile
  2127. Xfile it reads the
  2128. Xfile
  2129. X.I ~/.ttyplaces
  2130. Xof the following format:
  2131. X
  2132. X.ta 1i
  2133. X.nf
  2134. Xoffice    Office: MCS 107 x9069
  2135. Xhome    Brookline, Ma
  2136. Xconsole    Console
  2137. Xprint    CS Printer Room
  2138. Xmachine    CS Machine Room
  2139. Xother    LOST IN SPACE
  2140. X.fi
  2141. X.ta
  2142. X.br
  2143. X
  2144. XThe user is prompted for each entry
  2145. X.B --home--
  2146. Xuntil an afirmative response (space, Y, y) is given.  Negative
  2147. Xreponses are rubout (delete key), N and n, no return is needed Q or q
  2148. Xto quit. Question mark gives help.
  2149. X
  2150. XIf the
  2151. X.B -h
  2152. Xflag is used and the terminal is determined to have a hardwired
  2153. Xlocation the user is not prompted.  The
  2154. X.B -f
  2155. Xflag forces
  2156. X.I ttyask
  2157. Xto read an alternate
  2158. X.I ttyplaces
  2159. Xfile.
  2160. X
  2161. XThe
  2162. X.B -t
  2163. X.I time
  2164. Xoption causes
  2165. X.I ttyask
  2166. Xto timeout if a location is not selected in
  2167. X.I time
  2168. Xseconds.
  2169. X
  2170. X.I Ttyplace
  2171. Xis an alias for
  2172. X.I ttyask -a
  2173. Xthat accepts a string argument that is searched for in the
  2174. X.I ttyplaces
  2175. Xfile.
  2176. X
  2177. X.I Ttyrandom
  2178. Xis an alias of
  2179. X.I ttyask -r
  2180. Xthat randomly selects a ttyloc from the ttyplaces file.
  2181. XWith the
  2182. X.B -t
  2183. X.I time
  2184. Xoption it will pick a new ttyloc every
  2185. X.I time
  2186. Xseconds.
  2187. X
  2188. X.I Ttycycle
  2189. Xis an alias of
  2190. X.I ttyask -c
  2191. Xthat sequences through the location in the ttyplaces file.  The
  2192. Xdefault cycle time is 60 seconds, and can be set with the
  2193. X.B -t
  2194. X.I time
  2195. Xoption.
  2196. X
  2197. XAll of
  2198. X.I ttyask, ttyplace, ttycycle,
  2199. Xand
  2200. X.I ttyrandom
  2201. Xaccept the flags
  2202. X.TP
  2203. X.B -a
  2204. Xforce into
  2205. X.I ttyask
  2206. Xmode
  2207. X.TP
  2208. X.B -p
  2209. Xforce into
  2210. X.I ttyplace
  2211. Xmode
  2212. X.TP
  2213. X.B -r
  2214. Xforce into
  2215. X.I ttyrandom
  2216. Xmode
  2217. X.TP
  2218. X.B -c
  2219. Xforce into
  2220. X.I ttycycle
  2221. Xmode
  2222. X
  2223. X.SH FILES
  2224. X.ta 2i
  2225. X.nf
  2226. X/usr/spool/ttyloc    user set ttyloc files
  2227. X~/.ttyplaces    locations for ttyask/ttyplace/ttyrandom
  2228. X/etc/nttyloc    new format default locations
  2229. X/etc/ttyloc    for per-line system default ttylocs (old form)
  2230. X/etc/ttytype    (4.2 only) used to determine hardwire-ness (or lack thereof)
  2231. X/etc/ttys    (4.3 only) used for ttytype (hardwire) and fallback location
  2232. X.fi
  2233. X.ta
  2234. X.SH SEE ALSO
  2235. X.IR finger (1),
  2236. X.IR nttyloc (5)
  2237. X.SH AUTHOR
  2238. XPhilip L. Budne, Boston University
  2239. END_OF_ttyloc.1
  2240. if test 3045 -ne `wc -c <ttyloc.1`; then
  2241.     echo shar: \"ttyloc.1\" unpacked with wrong size!
  2242. fi
  2243. # end of overwriting check
  2244. fi
  2245. if test -f ttyloc.c -a "${1}" != "-c" ; then 
  2246.   echo shar: Will not over-write existing file \"ttyloc.c\"
  2247. else
  2248. echo shar: Extracting \"ttyloc.c\" \(4467 characters\)
  2249. sed "s/^X//" >ttyloc.c <<'END_OF_ttyloc.c'
  2250. X/*
  2251. X * ttyloc.c -- Set Terminal Location (December 1985)
  2252. X *
  2253. X * Copyright (C) 1986, 1990  Philip L. Budne
  2254. X *
  2255. X * This file is part of "Phil's Finger Program".
  2256. X *
  2257. X * This program is free software; you can redistribute it and/or modify
  2258. X * it under the terms of the GNU General Public License as published by
  2259. X * the Free Software Foundation; either version 1, or (at your option)
  2260. X * any later version.
  2261. X *
  2262. X */
  2263. X
  2264. X# ifndef lint
  2265. Xstatic char *rcsid = "$Id: ttyloc.c,v 3.0 90/07/06 13:12:02 budd Rel $";
  2266. X# endif /* lint not defined */
  2267. X
  2268. X# include <sys/types.h>
  2269. X# include <sys/stat.h>
  2270. X# include <strings.h>
  2271. X# include <errno.h>
  2272. X# include <ctype.h>
  2273. X# include <stdio.h>
  2274. X# include "finger.h"
  2275. X
  2276. Xextern int errno;
  2277. X
  2278. X# define LCLEN 100            /* location length */
  2279. X# define FNLEN 100            /* file name length */
  2280. Xchar *argv0;
  2281. X
  2282. XGLOBAL char localhost[ MAXHOSTLEN+1 ];
  2283. X
  2284. Xextern char *ttyname();            /* from library */
  2285. Xextern char *locname();            /* from locname.c! */
  2286. XFORWARD LOCAL char *gettname();
  2287. XFORWARD LOCAL void getlocation(), fatal(), checkown(), pfatal(), checkdevice();
  2288. X
  2289. XGLOBAL int main( argc, argv )
  2290. X    int argc;
  2291. X    char *argv[];
  2292. X{
  2293. X    int len;                /* length of ttyloc string */
  2294. X    FILE *f;
  2295. X    BOOL frobbing;            /* true if ttyfrob */
  2296. X    char *tname;
  2297. X    char locstr[LCLEN], *tfname;
  2298. X
  2299. X    gethostname( localhost, MAXHOSTLEN );
  2300. X
  2301. X    argv0 = "ttyloc?";
  2302. X    frobbing = FALSE;
  2303. X
  2304. X    if( argc > 0 ) {
  2305. X    argv0 = rindex( argv[0], '/' );
  2306. X    if( argv0 == NULL )
  2307. X        argv0 = argv[0];
  2308. X    else
  2309. X        argv0++;
  2310. X
  2311. X    if( strcmp(argv0, "ttyfrob") == 0 )
  2312. X        frobbing = TRUE;
  2313. X
  2314. X    argc--;
  2315. X    argv++;
  2316. X    }
  2317. X
  2318. X    if( frobbing ) {
  2319. X    if( argc > 0 ) {
  2320. X        tname = argv[0];
  2321. X        argc--;
  2322. X        argv++;
  2323. X        checkdevice( tname );
  2324. X    } /* more args */
  2325. X    else
  2326. X        fatal("must have tty name");
  2327. X    } /* frobbing */
  2328. X    else {
  2329. X    char *dev;
  2330. X# if 0                    /* returns /dev/tty! */
  2331. X    dev = ctermid( NULL );
  2332. X    if( dev == NULL )
  2333. X# endif /* 0 */
  2334. X        dev = ttyname( 0 );
  2335. X    if( dev == NULL )
  2336. X        fatal("could not find tty!");
  2337. X    checkown( dev );
  2338. X    tname = gettname( dev );
  2339. X    }
  2340. X    getlocation(locstr, argc, argv);
  2341. X
  2342. X    tfname = locname( tname );        /* get spool file name */
  2343. X
  2344. X    len = strlen(locstr);
  2345. X    if( len == 0 ) {
  2346. X    if( unlink( tfname ) < 0 && errno != ENOENT )
  2347. X        pfatal("could not unlink %s", tfname );
  2348. X    exit( 0 );
  2349. X    }
  2350. X
  2351. X    f = fopen( tfname, "w" );
  2352. X    if( f == NULL )
  2353. X    pfatal("could not open %s");
  2354. X
  2355. X    fputs( locstr, f );            /* check return? */
  2356. X
  2357. X# ifdef USG
  2358. X    chmod( tfname, TTYLOC_MODE );
  2359. X# else  /* USG not defined */
  2360. X    fchmod(fileno(f), TTYLOC_MODE);
  2361. X# endif /* USG not defined */
  2362. X    fclose( f );            /* check for err? */
  2363. X    return( 0 );            /* ANSI! */
  2364. X} /* main */
  2365. X
  2366. XLOCAL void checkdevice( s )
  2367. X    char *s;
  2368. X{
  2369. X    char devname[20];
  2370. X
  2371. X    strcpy(devname, "/dev/");
  2372. X    strcat(devname, s);
  2373. X    checkown( devname );
  2374. X} /* checkdevice */
  2375. X
  2376. XLOCAL char *gettname( device )
  2377. X    char *device;
  2378. X{
  2379. X    device = rindex(device, '/');
  2380. X    if( device != NULL )
  2381. X    device++;            /* skip over last slash */
  2382. X    return( device );
  2383. X} /* getttname */
  2384. X
  2385. XLOCAL void getlocation(locstr, count, vec)
  2386. Xchar *locstr;
  2387. Xint count;
  2388. Xchar *vec[];
  2389. X{
  2390. X    register char *cp, *sp;
  2391. X
  2392. X    cp = locstr;
  2393. X    *cp = EOS;
  2394. X
  2395. X    while( count > 0 ) {
  2396. X    sp = vec[0];
  2397. X    if( cp != locstr )
  2398. X        *cp++ = ' ';
  2399. X
  2400. X    while( *sp != EOS ) {
  2401. X        if( isprint( *sp ) )
  2402. X        *cp++ = *sp;
  2403. X        else
  2404. X        fprintf( stderr, "%%%s: ignoring non printing character 0%o\n",
  2405. X            argv0, *sp & 0xff );
  2406. X        sp++;
  2407. X    }
  2408. X    count--;
  2409. X    vec++;
  2410. X    }
  2411. X    if( cp != locstr )
  2412. X    *cp++ = '\n';
  2413. X    *cp = EOS;
  2414. X} /* getlocation */
  2415. X
  2416. XLOCAL void fatal( s, x )
  2417. Xchar *s;
  2418. Xint x;
  2419. X{
  2420. X    char line[ 1024 ];
  2421. X    sprintf( line, s, x );
  2422. X    fprintf(stderr, "?%s: %s\n", argv0, line );
  2423. X    exit( 1 );
  2424. X} /* fatal */
  2425. X
  2426. XLOCAL void pfatal( s, x )
  2427. Xchar *s;
  2428. Xint x;
  2429. X{
  2430. X    extern int errno, sys_nerr;
  2431. X    extern char *sys_errlist[];
  2432. X    char line[ 1024 ];
  2433. X
  2434. X    sprintf( line, s, x );
  2435. X    if( errno > 0 && errno < sys_nerr )
  2436. X    fprintf(stderr, "?%s: %s; %s\n", argv0, line, sys_errlist[ errno ] );
  2437. X    else
  2438. X    fprintf(stderr, "?%s: %s; error %d\n", argv0, line, errno );
  2439. X    exit( 1 );
  2440. X} /* pfatal */
  2441. X
  2442. XLOCAL void checkown( name )
  2443. X    char *name;
  2444. X{
  2445. X    struct stat stb;
  2446. X    int uid;
  2447. X
  2448. X    if( stat( name, &stb ) < 0 ) {
  2449. X    pfatal("could not stat %s", name );
  2450. X    exit( 1 );
  2451. X    } /* stat ok */
  2452. X    if( (stb.st_mode & S_IFMT) != S_IFCHR )
  2453. X    fatal("%s is not a character device!");
  2454. X    uid = getuid();            /* get invoker's uid */
  2455. X    if( uid != 0 && stb.st_uid != uid )
  2456. X    fatal( "not owner of %s", name );
  2457. X} /* checkown */
  2458. X
  2459. X
  2460. X/*
  2461. X * Local variables:
  2462. X * comment-column: 40
  2463. X * End:
  2464. X */
  2465. END_OF_ttyloc.c
  2466. if test 4467 -ne `wc -c <ttyloc.c`; then
  2467.     echo shar: \"ttyloc.c\" unpacked with wrong size!
  2468. fi
  2469. # end of overwriting check
  2470. fi
  2471. if test -f uptime.c -a "${1}" != "-c" ; then 
  2472.   echo shar: Will not over-write existing file \"uptime.c\"
  2473. else
  2474. echo shar: Extracting \"uptime.c\" \(1934 characters\)
  2475. sed "s/^X//" >uptime.c <<'END_OF_uptime.c'
  2476. X/*
  2477. X * uptime.c -- /usr/ucb/uptime replacement for USG systems
  2478. X *
  2479. X * Copyright (C) 1989, 1990  Philip L. Budne
  2480. X *
  2481. X * This file is part of "Phil's Finger Program".
  2482. X *
  2483. X * This program is free software; you can redistribute it and/or modify
  2484. X * it under the terms of the GNU General Public License as published by
  2485. X * the Free Software Foundation; either version 1, or (at your option)
  2486. X * any later version.
  2487. X *
  2488. X */
  2489. X
  2490. X# ifndef lint
  2491. Xstatic char *rcsid = "$Id: uptime.c,v 3.0 90/07/06 13:12:10 budd Rel $";
  2492. X# endif /* lint not defined */
  2493. X
  2494. X# include <stdio.h>
  2495. X# include <sys/types.h>
  2496. X# include <time.h>
  2497. X# include <utmp.h>
  2498. X
  2499. Xmain() {
  2500. X    struct utmp *ut;
  2501. X    time_t boot, now;
  2502. X    struct tm *tm;
  2503. X    int users, hour, min, day, items;
  2504. X    char am;
  2505. X
  2506. X    users = boot = 0;
  2507. X    setutent();
  2508. X    while( (ut = getutent()) )
  2509. X    switch( ut->ut_type ) {
  2510. X    case BOOT_TIME:
  2511. X        boot = ut->ut_time;
  2512. X        break;
  2513. X    case USER_PROCESS:
  2514. X        users++;
  2515. X        break;
  2516. X    }
  2517. X
  2518. X    time( &now );
  2519. X    tm = localtime( &now );
  2520. X
  2521. X    hour = tm->tm_hour;
  2522. X    am = 'a';
  2523. X    if( hour == 0 )            /* fix midnight */
  2524. X    hour = 12;
  2525. X    else if( hour > 11 ) {        /* after 11AM */
  2526. X    am = 'p';            /* its after-noon */
  2527. X    if( hour > 12 )            /* but don't touch 12!! */
  2528. X        hour -= 12;
  2529. X    } /* pm */
  2530. X    printf("%2d:%02d%cm  ", hour, tm->tm_min, am );
  2531. X
  2532. X    items = 0;
  2533. X    if( boot != 0 ) {
  2534. X    int min, day;
  2535. X    boot = now - boot;        /* get time since boot */
  2536. X    boot /= 60;            /* get minutes */
  2537. X
  2538. X    min = boot % 60;
  2539. X    boot /= 60;            /* toss mins */
  2540. X
  2541. X    hour = boot % 24;        /* get hours */
  2542. X    boot /= 24;
  2543. X
  2544. X    day = boot % 7;
  2545. X    boot /= 7;
  2546. X
  2547. X    printf("up ");
  2548. X
  2549. X# define PUTF(what,n)\
  2550. X    { if( items++ > 0 ) { putchar(','); putchar(' '); } \
  2551. X    printf("%d %s", n, what); if( n != 1 ) putchar('s'); }
  2552. X
  2553. X    if( boot > 0 )
  2554. X        PUTF("week", boot );
  2555. X
  2556. X    if( day > 0 )
  2557. X        PUTF("day", day );
  2558. X
  2559. X    if( hour > 0 )
  2560. X        PUTF("hour", hour );
  2561. X
  2562. X    if( min > 0 )
  2563. X        PUTF("minute", min );
  2564. X    } /* have boot */
  2565. X
  2566. X    PUTF("user", users );
  2567. X    putchar('\n');
  2568. X}
  2569. END_OF_uptime.c
  2570. if test 1934 -ne `wc -c <uptime.c`; then
  2571.     echo shar: \"uptime.c\" unpacked with wrong size!
  2572. fi
  2573. # end of overwriting check
  2574. fi
  2575. if test -f ustruct.h -a "${1}" != "-c" ; then 
  2576.   echo shar: Will not over-write existing file \"ustruct.h\"
  2577. else
  2578. echo shar: Extracting \"ustruct.h\" \(2568 characters\)
  2579. sed "s/^X//" >ustruct.h <<'END_OF_ustruct.h'
  2580. X/*
  2581. X * ustruct.h -- system includes for user struct
  2582. X *
  2583. X * Copyright (C) 1986, 1990  Philip L. Budne
  2584. X *
  2585. X * This file is part of "Phil's Finger Program".
  2586. X *
  2587. X * This program is free software; you can redistribute it and/or modify
  2588. X * it under the terms of the GNU General Public License as published by
  2589. X * the Free Software Foundation; either version 1, or (at your option)
  2590. X * any later version.
  2591. X *
  2592. X */
  2593. X
  2594. X# define USTRUCT_RCSID "$Id: ustruct.h,v 3.0 90/07/06 13:12:14 budd Rel $"
  2595. X
  2596. X# ifdef accel
  2597. X# define INCLUDE_HEADERS
  2598. X# endif /* accel defined */
  2599. X
  2600. X# include <sys/param.h>            /* everyone!! */
  2601. X
  2602. X# ifdef USG
  2603. X
  2604. X# include <sys/types.h>
  2605. X# include <sys/time.h>            /* for proc.h */
  2606. X# include <sys/signal.h>        /* for MAXSIG */
  2607. X
  2608. X# ifdef sgi
  2609. X# include <sys/syssgi.h>
  2610. X# endif /* sgi defined */
  2611. X
  2612. X# ifdef SYSI86
  2613. X# include <sys/sysi86.h>
  2614. X# endif /* SYSI86 defined */
  2615. X
  2616. X# ifndef AIX_RT                /* PC/RT AIX uses VRM segments */
  2617. X
  2618. X# ifdef AIX3
  2619. X
  2620. X# include <procinfo.h>
  2621. X
  2622. X# else  /* AIX3 not defined */
  2623. X
  2624. X# ifdef AUX                /* SVR2 */
  2625. X
  2626. X# include <sys/mmu.h>
  2627. X# include <sys/page.h>
  2628. X# include <sys/seg.h>            /* for proc.h */
  2629. X# include <sys/region.h>        /* for proc.h */
  2630. X
  2631. X# else  /* AUX not defined */
  2632. X
  2633. X# ifndef AIX_PS2
  2634. X
  2635. X/* SVR3: UmaxV, 386/ix */
  2636. X
  2637. X# ifdef DIR_H
  2638. X# include <sys/dir.h>            /* for dirent u_dent */
  2639. X# else  /* DIR_H not defined */
  2640. X# include <sys/fs/s5dir.h>        /* for dirent u_dent */
  2641. X# endif /* DIR_H not defined */
  2642. X
  2643. X# ifndef SYSI86
  2644. X/* for UmaxV, sgi */
  2645. X# include <sys/sbd.h>            /* for proc.h (p_ubptbl[])*/
  2646. X# endif /* SYSI86 not defined */
  2647. X
  2648. X# include <sys/immu.h>            /* for region.h */
  2649. X# include <sys/region.h>        /* for preg_t p_region */
  2650. X
  2651. X# endif /* AIX_PS2 not defined */
  2652. X# endif /* AUX not defined */
  2653. X
  2654. X# endif /* AIX3 not defined */
  2655. X
  2656. X# endif /* AIX_RT not defined */
  2657. X
  2658. X# else  /* USG not defined */
  2659. X
  2660. X/* BSD systems here */
  2661. X
  2662. X# if defined(bsd4_3) || defined(ultrix)    /* ifdef NI_DENT?? */
  2663. X# include <sys/dir.h>            /* for direct ni_dent in namei.h */
  2664. X# endif /* defined(bsd4_3) || defined(ultrix) */
  2665. X
  2666. X# if SunOS < 400
  2667. X# include <sys/vm.h>
  2668. X# ifndef accel
  2669. X# include <machine/pte.h>
  2670. X# endif /* accel not defined */
  2671. X# endif /* SunOS < 400 */
  2672. X
  2673. X# if SunOS >= 410
  2674. X# include <sys/session.h>
  2675. X# endif /* SunOS >= 410 */
  2676. X
  2677. X# endif /* USG not defined */
  2678. X
  2679. X/* everyone!! */
  2680. X# include <sys/user.h>
  2681. X# include <sys/proc.h>            /* for p_pid */
  2682. X# undef u                /* sgi defines macro */
  2683. X
  2684. X# ifndef SHORT_TTYP            /* SVR2, BSD, SOS3.x */
  2685. X# ifdef TTY_REQUIRES_IOCTL        /* 4.3, Ultrix */
  2686. X# include <sys/ioctl.h>
  2687. X# endif /* TTY_REQUIRES_IOCTL defined */
  2688. X# include <sys/tty.h>            /* for t_pgrp, t_{raw,out}q */
  2689. X# endif /* SHORT_TTYP not defined */
  2690. END_OF_ustruct.h
  2691. if test 2568 -ne `wc -c <ustruct.h`; then
  2692.     echo shar: \"ustruct.h\" unpacked with wrong size!
  2693. fi
  2694. # end of overwriting check
  2695. fi
  2696. if test -f whoj.c -a "${1}" != "-c" ; then 
  2697.   echo shar: Will not over-write existing file \"whoj.c\"
  2698. else
  2699. echo shar: Extracting \"whoj.c\" \(2769 characters\)
  2700. sed "s/^X//" >whoj.c <<'END_OF_whoj.c'
  2701. X/*
  2702. X * whoj.c -- whoj style output for finger
  2703. X *
  2704. X * Copyright (C) 1986, 1990  Philip L. Budne
  2705. X *
  2706. X * This file is part of "Phil's Finger Program".
  2707. X *
  2708. X * This program is free software; you can redistribute it and/or modify
  2709. X * it under the terms of the GNU General Public License as published by
  2710. X * the Free Software Foundation; either version 1, or (at your option)
  2711. X * any later version.
  2712. X *
  2713. X */
  2714. X
  2715. X# ifndef lint
  2716. Xstatic char *rcsid = "$Id: whoj.c,v 3.0 90/07/06 13:12:21 budd Rel $";
  2717. X# endif /* lint not defined */
  2718. X
  2719. X# include <sys/types.h>
  2720. X# include <stdio.h>
  2721. X# include "output.h"
  2722. X# include "args.h"            /* for luser.h */
  2723. X# include "luser.h"
  2724. X# include "finger.h"
  2725. X# include "pr.h"
  2726. X
  2727. Xextern LUSER *maketree();        /* from getent.c */
  2728. Xextern struct pr *getcommand();        /* from getcommand.c */
  2729. Xextern char *gtname();            /* from XXX */
  2730. Xextern void ptree();            /* from XXX */
  2731. X
  2732. Xstatic int whoj_termw;            /* whoj terminal name width */
  2733. Xstatic int whoj_userw;            /* whoj user name width */
  2734. Xstatic time_t now;            /* current time */
  2735. X
  2736. XLOCAL void whojwidth();            /* forward */
  2737. XLOCAL void whojuser();            /* forward */
  2738. X
  2739. XGLOBAL void dowhoj() {
  2740. X    LUSER *t;
  2741. X
  2742. X    time( &now );            /* get current time */
  2743. X    t = maketree();            /* build tree of utmp entries */
  2744. X    whoj_termw = whoj_userw = -1;
  2745. X    ptree( t, whojwidth );        /* figure widths */
  2746. X    ptree( t, whojuser );        /* print tree */
  2747. X} /* whoj */
  2748. X
  2749. XLOCAL int max(a, b)
  2750. Xint a, b;
  2751. X{
  2752. X    if( a > b )
  2753. X    return( a );
  2754. X    else
  2755. X        return( b );
  2756. X} /* max */
  2757. X
  2758. XLOCAL void whojwidth( u )
  2759. XLUSER *u;
  2760. X{
  2761. X    char *tn;
  2762. X    int tnl;
  2763. X
  2764. X    if( u->u_host[0] == EOS ) {        /* no host? */
  2765. X    tn = gtname( u->u_line );    /* remove tty from line name */
  2766. X    tnl = strlen( tn );
  2767. X    if( tn != u->u_line )        /* it did? */
  2768. X        tnl++;            /* yes, add back a 't' */
  2769. X    }
  2770. X    else {
  2771. X    undomain( u->u_host, TRUE );     /* remove domains and prefixes */
  2772. X        tnl = strlen( u->u_host );
  2773. X    }
  2774. X
  2775. X    whoj_termw = max( tnl, whoj_termw );
  2776. X    whoj_userw = max( strlen( u->u_user ), whoj_userw );
  2777. X} /* whojwidth */
  2778. X
  2779. XLOCAL void whojuser( u )
  2780. XLUSER *u;
  2781. X{
  2782. X    struct pr *pr;
  2783. X    char line[MAXLINE],            /* output line */
  2784. X        *tn,                /* return from gtname */
  2785. X        tname[20],            /* terminal name to output */
  2786. X        *cmd;                /* command to output */
  2787. X
  2788. X    line[0] = EOS;
  2789. X    if( u->u_host[0] == EOS ) {
  2790. X    tn = gtname( u->u_line );
  2791. X    if( tn != u->u_line ) {
  2792. X        tname[0] = 't';
  2793. X        strcpy(&tname[1], tn);
  2794. X        tn = tname;
  2795. X    }
  2796. X    }
  2797. X    else
  2798. X        tn = u->u_host;
  2799. X
  2800. X    termstat( u );            /* needed for getcommand */
  2801. X    pr = getcommand( u );
  2802. X    if( pr != NULL )
  2803. X    cmd = pr->pr_cmd;
  2804. X    else
  2805. X    cmd = "?";
  2806. X
  2807. X    sprintf(line,
  2808. X        "%*s  %*s  %s",
  2809. X        -whoj_termw,
  2810. X        tn,
  2811. X        -whoj_userw,
  2812. X        u->u_user,
  2813. X        cmd
  2814. X        );
  2815. X    outline(line);
  2816. X} /* whojuser */
  2817. X
  2818. X/*
  2819. X * Local variables:
  2820. X * comment-column: 40
  2821. X * End:
  2822. X */
  2823. END_OF_whoj.c
  2824. if test 2769 -ne `wc -c <whoj.c`; then
  2825.     echo shar: \"whoj.c\" unpacked with wrong size!
  2826. fi
  2827. # end of overwriting check
  2828. fi
  2829. echo shar: End of archive 2 \(of 7\).
  2830. cp /dev/null ark2isdone
  2831. MISSING=""
  2832. for I in 1 2 3 4 5 6 7 ; do
  2833.     if test ! -f ark${I}isdone ; then
  2834.     MISSING="${MISSING} ${I}"
  2835.     fi
  2836. done
  2837. if test "${MISSING}" = "" ; then
  2838.     echo You have unpacked all 7 archives.
  2839.     rm -f ark[1-9]isdone
  2840. else
  2841.     echo You still need to unpack the following archives:
  2842.     echo "        " ${MISSING}
  2843. fi
  2844. ##  End of shell archive.
  2845. exit 0
  2846.  
  2847.